Code: Test class
public class MyTestTimer {
public static Timer mTimer;
public static void main(String[] args) {
mTimer=new Timer();
MyTimerTask testTimer=new MyTimerTask(10000);
mTimer.schedule(testTimer, 10000);
}
}TimerTask task class
public class MyTimerTask extends TimerTask{
private int second;
public MyTimerTask(int second) {
this.second=second;
}
public void run() {
System.out.println("我等你等了"+second+"秒");
}
}The above simple demo (sharing) of Timer and TimerTask in java is The editor has shared all the content with you. I hope it can give you a reference. I also hope that everyone will support the PHP Chinese website.
For more Java Timer and TimerTask simple demo (sharing) related articles, please pay attention to the PHP Chinese website!
What is ESD file?
What is the article tag used to define?
How to solve parsererror error
How to solve the problem of black screen after turning on the computer and unable to enter the desktop
How to configure jsp virtual space
Complete collection of SQL query statements
what is css
what is adobe flash player