📄 clockthread.java
字号:
import java.io.IOException;
public class clockthread extends Thread{
int time;
String process;
boolean stopflag,startflag;
public clockthread( int time,String process){
this.time=time;
this.process=process;
stopflag=true;//控制计数器是否运行,其为TURE说明计数器停止(即游戏程序没有运行)
startflag=false;//保证只运行线程的方法Start()一次,防止多次调用Start()发生错误
}
public void run(){
while(true){
while(!stopflag){
clock();
if(time!=1)
{
time--;
}
try {
sleep(1000);
}
catch(InterruptedException e)
{
return;
}
}
try {
sleep(1000);
}
catch(InterruptedException e)
{
return;
}
}
}
public void clock(){
if(time==5){
System.out.println("还差5分钟结束");
}
else if(time==1){
System.out.println("时间到关闭");
try{
Process p = Runtime.getRuntime().exec("taskkill /F /im IPMsg(文件传输).exe");
//p.destroy();
}catch(Exception e) {
e.printStackTrace();
}
}
/*switch(time){
case 5:
System.out.println("还差5分钟结束");break;
case 1:
System.out.println("时间到关闭");
try{
Process p = Runtime.getRuntime().exec("taskkill /F /im IPMsg(文件传输).exe");
//p.destroy();
}catch(Exception e) {
e.printStackTrace();
}
break;
default :
break;
} */
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -