There are a range of solutions to this problem, with Thread.sleep() being the
simplest. Obviously for the *best* performance this is not optimal because no
matter what, we always wait the specified sleep period.
Two additional solutions spring to mind:
1. Use wait() and notifyAll() for interthread communication
2. Roll your own thread manager
Attached is an article that describes a number of approaches:
http://www.javaworld.com/javaworld/jw-11-1998/jw-11-toolbox_p.html
There is probably no single greatest solution. You need to look at the needs of
the program and the environment in which it runs and implement the solution
that best fits.
There are a range of solutions to this problem, with Thread.sleep() being the simplest. Obviously for the *best* performance this is not optimal because no matter what, we always wait the specified sleep period.
Two additional solutions spring to mind: 1. Use wait() and notifyAll() for interthread communication 2. Roll your own thread manager
Attached is an article that describes a number of approaches: http://www.javaworld.com/javaworld/jw-11-1998/jw-11-toolbox_p.html
There is probably no single greatest solution. You need to look at the needs of the program and the environment in which it runs and implement the solution that best fits.
Brendon.