Suspend and Resume Java

The sleep(long inactivateTime) method takes a parameter of how much time the thread should be inactivated (sent to blocked state). The advantage of sleep() method is the thread comes into activation (getting into runnable state) when the inactivateTime is over automatically.

When the inactivation time of a thread is not known at compile time and known at runtime only, then prefer suspend() method. A thread suspended goes into blocked state. How long? Until you call resume() method.

suspend() and resume() methods are deprecated and when not used wisely on synchronized blocks, the system may hang (goes into deadlock).

Following link gives the usage of suspend() and resume() methods.

Suspending and Resuming a Thread
For all programs on multithreading

Multithreading at a Glance

Leave a Comment

Your email address will not be published.