Thread Methods destroy() and stop(Throwable) Removed in JDK 11
source link: https://www.tuicool.com/articles/hit/NJnyE3b
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
The message " RFR(s): 8204243: remove Thread.destroy() and Thread.stop(Throwable) " by @DrDeprecator (Stuart Marks) on the core-libs-dev OpenJDK mailing list is a request for review (RFR) of a changeset associated with JDK-8204243 ["remove Thread.destroy() and Thread.stop(Throwable)"]. Both the bug report and the mailing list message describe the history of these two referenced Thread methods and explain that neither method really does anything useful.
The JDK 10 Javadoc API documentation
for the java.lang.Thread
shows six methods on the Thread
class that are deprecated. Three of which are explicitly marked for removal. The table below summarizes these deprecated Thread
methods.
DEPRECATED
SINCE
FOR
REMOVAL?
JDK 10
STATUS
countStackFrames() 1.2 Yes Depends on deprecatedsuspend()
destroy()
1.5
Yes
Throws NoSuchMethodError
since inception ( never implemented ) resume() 1.2 No " Exists solely for use with
suspend()
"
stop()
1.2
No
" This method is inherently unsafe.
"
stop(Throwable)
1.2
Yes
Throws
UnsupportedOperationException
since JDK 8
suspend()
1.2
No
" This method ... is inherently deadlock-prone.
"
It now appears that two of the three Thread
methods that are deprecated and
marked for removal will be removed with JDK 11. These methods include Thread.destroy()
and Thread.stop(Throwable)
and they should be completely removed with the release of JDK 11. The destroy()
method has never done anything except throw the NoSuchMethodError.
The stop(Throwable)
method hasn't done anything except throw the UnsupportedOperationException
since JDK 8. Good riddance to these two fruitless methods!
Additional References
- Java Thread Primitive Deprecation
- How to Kill a Java Thread
- Why stop, suspend, and resume of Thread are Deprecated
- RFR(s): 8204243: remove Thread.destroy() and Thread.stop(Throwable)
- JDK-8204243 ["remove Thread.destroy() and Thread.stop(Throwable)"]
- JDK-8204260 ["remove Thread.destroy() and Thread.stop(Throwable)"]
- JDK-4102667 ["Thread.countStackFrames() should be a deprecated method."]
- JDK-8177680 ["Umbrella: Remove terminally deprecated APIs from JDK 11"]
- JDK-8177554 ["Umbrella: Remove terminally deprecated APIs from JDK 10"]
- Time to put a stop to Thread.stop? ( revisited )
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK