Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Thread Methods destroy() and stop(Throwable) Removed in JDK 11

DZone's Guide to

Thread Methods destroy() and stop(Throwable) Removed in JDK 11

Are these two Thread methods going away? Let's take a look in this post.

· Java Zone ·
Free Resource

How do you break a Monolith into Microservices at Scale? This ebook shows strategies and techniques for building scalable and resilient microservices.

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.

METHODS DEPRECATED IN JAVA.LANG.THREAD AS OF JDK 10
METHOD DEPRECATED
SINCE
FOR
REMOVAL?
JDK 10
STATUS
countStackFrames() 1.2 Yes Depends on deprecated suspend()
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 ThrowsUnsupportedOperationException 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 theUnsupportedOperationException since JDK 8. Good riddance to these two fruitless methods!

Additional References

How do you break a Monolith into Microservices at Scale? This ebook shows strategies and techniques for building scalable and resilient microservices.

Topics:
java ,jdk 11 ,threads ,methods ,deprecation ,api

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}