Avoid Calling Thread.destroy()
ID |
java.thread_destroy_removed |
Severity |
info |
Remediation Complexity |
trivial |
Remediation Risk |
low |
Remediation Effort |
low |
Resource |
Efficiency |
Language |
Java |
Tags |
best-practice, concurrency |
Description
Reports calls to Thread.destroy(). This method has been deprecated since its introduction and was removed in later JDK versions.
Rationale
Thread.destroy() was intended to forcefully destroy a thread without releasing any monitors it held. This could leave shared data structures in an inconsistent state and cause deadlocks. The method was never implemented in most JVMs and throws UnsupportedOperationException or NoSuchMethodError in modern JDKs.
// Bad -- deprecated/removed API
thread.destroy();