title: Java Wake Sleeping Thread
body: <p>I did some reading of other post but didn't find an exact answer to what I'm looking for, so I hope someone can give some some clarification.</p>
  
  <p>I have a program that will run for some time. I have some threads that run in the back ground that perform various tasks, to keep things simple let think of 3 threads. <code>ThreadA</code> performs a task every 10 seconds, where <code>ThreadB</code> does something every 30 seconds and <code>ThreadC</code> does something every 5 mintues.</p>
  
  <p>I don't use busy waiting, and put the threads to sleep for the designated times.</p>
  
  <p>My question is regarding a clean shut down. I have a variable that each of the threads have read access too, so they can see when the user initiates the exit of the program. The next time the threads are active, they exit their loops and join and all is good. But you can see that ThreadC only wakes up every 5 minutes.</p>
  
  <p>The question I have is can I signal the sleeping threads to wake up and exit before their sleep time is over? If this is not possible, do I need to rework the code to use <code>wait()</code> and <code>notify()</code> or is there a better way?</p>