Wednesday 11 May 2016

Why are Thread.suspend and Thread.resume deprecated?

suspend() method is deadlock prone. If the target thread holds a lock on object when it is suspended, no thread can lock this object until the target thread is resumed. If the thread that would resume the target thread attempts to lock this monitor prior to calling resume, deadlock results. These deadlocks are generally called frozen processes.
suspend() method puts thread from running to waiting state. And thread can go from waiting to runnable state only when resume() method is called on thread. It is deprecated method.
resume() method is only used with suspend() method that’s why it’s also deprecated method.

Referenceoracle docs

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...