On Thu, 23 Nov 2023 09:18:44 GMT, Alan Bateman <al...@openjdk.org> wrote:

> The deadlock prone Thread/ThreadGroup suspend/resume were deprecated since 
> JDK 1.2, deprecated for removal in Java 14, and re-specified/degraded to 
> throw UnsupportedOperationException unconditionally in Java 19/20.  Early in 
> Java 23 seems a fine time to finally remove these methods.
> 
> Corpus analysis of 176 million classes in 485k artifacts found no remaining 
> usages of ThreadGroup.suspend/resume beyond the artifacts that include a copy 
> of java.lang.ThreadGroup (!). It found 87 remaining uses of Thread.suspend 
> and 86 remaining usages of Thread.resume, some of these are tests.
> 
> Thread.suspend/resume have always linked to the "Java Thread Primitive 
> Deprecation" page. This originally explained the reasons why suspend/resume 
> were deprecated. When these methods were degraded to throw UOE we changed the 
> text to explain why the ability to suspend or resume a thread was removed. 
> Now we must change it again. One choice is to re-word to explain why the Java 
> APIs were removed or why the Java APIs don't define a way to suspend/resume 
> threads, the other choice (which I prefer) is to remove the text.
> 
> The method description of java.lang.management.ThreadInfo.isSuspended is 
> tweaked to link to JVMTI SuspendThread instead of Thread.suspend

Looks good to me. I'm okay with removing the suspend/resume text from the 
deprecation page - no point trying to explain a 25+ year history.

Couple of queries on the test changes, but still approved.

Thanks

test/jdk/java/lang/Thread/ThreadStopTest.java line 27:

> (failed to retrieve contents of file, check the PR for context)
You didn't really need to rename the test even though there is now only one 
degraded method left.

test/jdk/java/nio/channels/SocketChannel/SendUrgentData.java line 67:

> 65:         if (args.length > 0 && args[0].equals("-server")) {
> 66:             System.out.println(serverThread.getAddress());
> 67:             Thread.currentThread().suspend();

If suspend throws then surely this test can't be functioning correctly! ???

-------------

Marked as reviewed by dholmes (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/16789#pullrequestreview-1747907612
PR Review Comment: https://git.openjdk.org/jdk/pull/16789#discussion_r1404325923
PR Review Comment: https://git.openjdk.org/jdk/pull/16789#discussion_r1404327680

Reply via email to