Interview Questions

Why destroy() methods is deprecated?

Java Interview Questions and Answers (part 4)


(Continued from previous question...)

26. Why destroy() methods is deprecated?

This question is again going to check your in depth knowledge of thread methods i.e. destroy() method is deadlock prone. If the target thread holds a lock on object when it is destroyed, no thread can lock this object (Deadlock formed are similar to deadlock formed when suspend() and resume() methods are used improperly). It results in deadlock formation. These deadlocks are generally called Frozen processes.

Additionally you must know calling destroy() method on Threads throw runtimeException i.e. NoSuchMethodError. Destroy() method puts thread from running to dead state.

(Continued on next question...)

Other Interview Questions