public class TimerTasks {
public static void main(String[] args) {
Timer time = new Timer();
Date startDate = new Date();
TimerTasks task = new TimerTasks();
final DriectoryManagement dmg = task.new DriectoryManagement();
time.schedule(new TimerTask() {
@Override
public void run() {
// TODO Auto-generated method stub
dmg.executes();
}
}, startDate, 1000);
try {
Thread.sleep(5000);
time.cancel();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public class DriectoryManagement {
int n;
public void executes() {
this.n++;
System.out.println("n:" + n);
}
}
}
http://tech.ddvip.com/2008-01/119991257740150_2.html
http://my.chinaunix.net/space.php?uid=24426415&do=blog&id=77453
http://www.kklinux.com/html/shujukujishu/BD2/200901/13-2542.html
http://database.51cto.com/art/201008/217966.htm
public static void main(String[] args) {
Timer time = new Timer();
Date startDate = new Date();
TimerTasks task = new TimerTasks();
final DriectoryManagement dmg = task.new DriectoryManagement();
time.schedule(new TimerTask() {
@Override
public void run() {
// TODO Auto-generated method stub
dmg.executes();
}
}, startDate, 1000);
try {
Thread.sleep(5000);
time.cancel();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public class DriectoryManagement {
int n;
public void executes() {
this.n++;
System.out.println("n:" + n);
}
}
}
http://tech.ddvip.com/2008-01/119991257740150_2.html
http://my.chinaunix.net/space.php?uid=24426415&do=blog&id=77453
http://www.kklinux.com/html/shujukujishu/BD2/200901/13-2542.html
http://database.51cto.com/art/201008/217966.htm