For example in the following code:
while(true)
{
doSomeThing(); //Do some operation once a day
wait(24 * 3600); //sleep for one day. LINE1
}
The thread blocks at LINE1 for one day. When the program shuts down,
if the notify() is missing, then the program will hang.
The wait/notify protocol is a synchronization tool for collaborating
threads, not a general-purpose delay mechanism. You probably want a
timer (ScheduledExecutor or java.util.Timer or something) to handle
once-an-interval events like this.
If you insist on tying up an entire thread's worth of memory and OS
resources on doing nothing, use Thread.sleep instead, and issue
shutdown notifications using Thread.interrupt as markspace suggested.
-o