仅供参考,没有去调。
public class CheckTime extends Thread {
int time;
boolean timeExpired = false;
public CheckTime(int time) { // second
this.time = time;
} public void run() {
try{
sleep(time*1000);
}catch(Exception e){}
timeExpired = true;
} public boolean expired() { return timeExpired;}
}class Testing {
public static void main(String[] a) {
CheckTime t = new CheckTime(3);
t.start();
while(!t.expired()) {
// do your processing
}
}
}
public class CheckTime extends Thread {
int time;
boolean timeExpired = false;
public CheckTime(int time) { // second
this.time = time;
} public void run() {
try{
sleep(time*1000);
}catch(Exception e){}
timeExpired = true;
} public boolean expired() { return timeExpired;}
}class Testing {
public static void main(String[] a) {
CheckTime t = new CheckTime(3);
t.start();
while(!t.expired()) {
// do your processing
}
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货