Chapter 4
Chapter 4
2) wait():
If a thread requires to wait until some event occurs, it can be done using wait method
and can be scheduled to run again by notify().
3) sleep():
We can put a thread to sleep for a specified time period using sleep(time) where time
is in ms.
It re-enters the runnable state as soon as period has elapsed /over
Dead State:
1. Whenever we want to stop a thread form running further we can call its stop().
2. The statement causes the thread to move to a dead state.
3. A thread will also move to dead state automatically when it reaches to end of the
method.
4. The stop method may be used when the premature death is required.