📄 timethread.java
字号:
package org.fangsoft.testcenter.main;
import java.sql.Timestamp;
import org.fangsoft.testcenter.model.Test;
import org.fangsoft.testcenter.model.TestResult;
import org.fangsoft.testcenter.view.console.ReportTestResultView;
public class TimeThread implements Runnable{
public Thread timeTread=null;
private Test test;
private TestResult tr;
//private long end;
//private long startTime;
public void start(Test test,TestResult tr){
if(timeTread==null){
timeTread=new Thread(this,"time");
timeTread.start();
this.test=test;
this.tr=tr;
//this.startTime=System.currentTimeMillis();
}
}
public void run(){
Thread myThread=Thread.currentThread();
try {
while(timeTread==myThread){
Thread.sleep(1000*10);
System.out.println("注意!你还有10秒!");
Thread.sleep(1000*10);
this.repaint();
}
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
private void repaint() {
// TODO Auto-generated method stub
tr.commitTest();
long end = System.currentTimeMillis();
tr.setEndTime(new Timestamp(end));
tr.updatte();
System.out.println("你的做答时间到!");
//Testcenter.reportTestResult(tr);
ReportTestResultView rv=new ReportTestResultView();
rv.setTr(tr);
rv.display();
this.stop();
Testcenter.exit(0);
}
public void stop(){
timeTread=null;
}
// public static void main(String agrs[]){
// TimeThread t=new TimeThread();
// t.start();
// }
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -