Let’s say you have N runnable objects, and for each you want them to execute for random periods of time. Once a runnable object executes for that time period, you want to reschedule it to run for another random period of time. You want to be able to do this for each of the runnables, multiple times.
Once a runnable is started, it should just perform something in an indefinite loop – that is the runnable should have no knowledge of how long it will run. From the runnable’s point of view, it will run indefinitely.
How can this be achieved, ideally using only the standard Java API? If this not possible to achieve as is, what alternate design would be closest?
You might find this simpler.