View Single Post
  #5 (permalink)  
Old 10-08-2008, 09:09 PM
fishtoprecords's Avatar
fishtoprecords fishtoprecords is offline
Senior Member
 
Join Date: Jun 2008
Posts: 522
fishtoprecords is on a distinguished road
Threads are how you do things in Java. They have been built into the language from the very first.

A cruder approach would be to put a Thread.sleep(50)
in your loop. But the real Java way is to have a separate timer thread, and use
CyclicBarrier or Semaphore to communicate.

The timer thread approach is more robust, as it can keep time independently of the worker thread. This is good, because you don't know how long each task is going to take the worker to do.
Reply With Quote