while(true){thread.sleep(time)} vs Timer.schedule,Timer Task vs Executor Service

时间:2014-04-16 10:29:01

标签: java timer infinite-loop executorservice timertask

我需要在一定的时间间隔内运行一个特定的线程。我在这个SO link中看到,使用timer与while(true)thread.sleep相同,如果我们使用它来延迟一段时间。这三种方法之间的区别是什么,以及上述三种方法中哪些方法有效,并且有助于降低CPU使用率。

0 个答案:

没有答案