跪求,运行结果
class MyTimerTask extends TimerTask {
public void run () {
System.out.println("my Running");
}
}
class Test {
public static void main (String[] args) {
final Timer timer = new Timer();
timer.schedule( new MyTimerTask(), 3000, 2000 );
new Thread( new Runnable(){
public void run(){
try {
Thread.sleep(7000);
timer.cancel();
} catch( InterruptedException e) {
e.printStackTrace();
}
}
}).start();
}
}
|
|