Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Advantages and disadvantages among Timer, ScheduledExecutorService, Thread

807580Aug 18 2010 — edited Aug 21 2010
Hi, what are the exact advantages and disadvantages among using Timer, using ScheduledExecutorService and just using Thread (Thread.sleep(...))?
For the simple task which needs to poll some values by some interval (the interval is not supposed very accurate, maybe about 5 seconds just ok), is it ok for just using Thread, like:
run() {
  while(isRunning) {
     Thread.sleep(5000);
     //do something
  }
}
?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 18 2010
Added on Aug 18 2010
7 comments
3,353 views