- Executors.newScheduledThreadPool(3).scheduleAtFixedRate(
- new Runnable(){
- @Override
- public void run() {
- // TODO Auto-generated method stub
- System.out.println("爆炸....." );
- }
- },
- 10, //延迟10秒执行run()
- 3, //之后每隔3秒执行一次run()
- TimeUnit.SECONDS
- );
- //scheduleWithFixedDelay和scheduleAtFixedRate的区别是什么啊????????执行结果没什么区别好像
- Executors.newScheduledThreadPool(3).scheduleWithFixedDelay(
- new Runnable() {
-
- @Override
- public void run() {
- // TODO Auto-generated method stub
- System.out.println("爆炸");
- }
- },
- 10,
- 3,
- TimeUnit.SECONDS
- );
复制代码 |
|