- import java.util.Date;
- class MyThread extends Thread {
- public void run() {
- while (true) {
- Date date = new Date();
- date.setHours(0);//only for test运行时注释本行
- System.out.println(date.getHours());
- if(0==(date.getHours()))
- System.out.println("delete");
- try {
- sleep(1000);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- }
- public static void main(String[] args) {
- new MyThread().start();
- }
- }
一个定时执行的线程
最新推荐文章于 2024-09-02 14:45:02 发布