首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

Timer的纷乱行为

2012-09-25 
Timer的混乱行为import java.util.Timerimport java.util.TimerTaskpublic class OutOfTime{??? public

Timer的混乱行为

import java.util.Timer;
import java.util.TimerTask;

public class OutOfTime
{
??? public static void main(String[] args) throws InterruptedException
??? {
??????? Timer timer = new Timer();
??????? timer.schedule(new ThrowTask(), 1);
??????? Thread.sleep(1000);
??????? timer.schedule(new ThrowTask(), 1);
??????? Thread.sleep(5000);
??? }

??? static class ThrowTask extends TimerTask
??? {
??????? public void run()
??????? {
??????????? throw new RuntimeException();
??????? }
??? }
}

热点排行