黑马程序员技术交流社区

标题: * 计时器 [打印本页]

作者: luojian    时间: 2016-4-13 23:40
标题: * 计时器
        public class Demo5_Timer {
                                /**
                                 * @param args
                                 * 计时器
                                 * @throws InterruptedException
                                 */
                                public static void main(String[] args) throws InterruptedException {
                                        Timer t = new Timer();
                                        t.schedule(new MyTimerTask(), new Date(114,9,15,10,54,20),3000);
                                       
                                        while(true) {
                                                System.out.println(new Date());
                                                Thread.sleep(1000);
                                        }
                                }
                        }
                        class MyTimerTask extends TimerTask {
                                @Override
                                public void run() {
                                        System.out.println("起床背英语单词");
                                }
                               
                        }





欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) 黑马程序员IT技术论坛 X3.2