From 704d35764bdf182e8ae2180ff9d4fd5749c43217 Mon Sep 17 00:00:00 2001 From: Alan Bateman Date: Tue, 4 Nov 2025 14:57:56 +0000 Subject: [PATCH 1/7] Initial commit --- .../java/lang/InterruptedException.java | 29 ++++----- .../share/classes/java/lang/Thread.java | 62 ++++++++++++++++--- 2 files changed, 64 insertions(+), 27 deletions(-) diff --git a/src/java.base/share/classes/java/lang/InterruptedException.java b/src/java.base/share/classes/java/lang/InterruptedException.java index ef13e5f94e309..6108392ebc85b 100644 --- a/src/java.base/share/classes/java/lang/InterruptedException.java +++ b/src/java.base/share/classes/java/lang/InterruptedException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,24 +26,19 @@ package java.lang; /** - * Thrown when a thread is waiting, sleeping, or otherwise occupied, - * and the thread is interrupted, either before or during the activity. - * Occasionally a method may wish to test whether the current - * thread has been interrupted, and if so, to immediately throw - * this exception. The following code can be used to achieve - * this effect: - * {@snippet lang=java : - * if (Thread.interrupted()) // Clears interrupted status! - * throw new InterruptedException(); - * } + * Thrown when a thread executing a blocking method is {@linkplain Thread#interrupt() + * interrupted}. {@link Thread#sleep(long)}, {@link Object#wait()} and many other + * blocking methods throw this exception if interrupted. + * + *

Blocking methods that throw {@code InterruptedException} clear the thread's + * interrupted status before throwing the exception. Code that catches {@code + * InterruptedException} should rethrow the exception, or reset the current thread's + * interrupted status, with {@link Thread#currentThread() Thread.currentThread()}. + * {@link Thread#interrupt() interrupt()}, before it continues normally or handles the + * exception by throwing another type of exception. * * @author Frank Yellin - * @see java.lang.Object#wait() - * @see java.lang.Object#wait(long) - * @see java.lang.Object#wait(long, int) - * @see java.lang.Thread#sleep(long) - * @see java.lang.Thread#interrupt() - * @see java.lang.Thread#interrupted() + * @see Thread##thread-interruption Thread Interruption * @since 1.0 */ public class InterruptedException extends Exception { diff --git a/src/java.base/share/classes/java/lang/Thread.java b/src/java.base/share/classes/java/lang/Thread.java index ace29f30a560f..9e68ee30f3d5e 100644 --- a/src/java.base/share/classes/java/lang/Thread.java +++ b/src/java.base/share/classes/java/lang/Thread.java @@ -63,8 +63,9 @@ *

A thread terminates if either its {@code run} method completes normally, * or if its {@code run} method completes abruptly and the appropriate {@linkplain * Thread.UncaughtExceptionHandler uncaught exception handler} completes normally or - * abruptly. With no code left to run, the thread has completed execution. The - * {@link #join() join} method can be used to wait for a thread to terminate. + * abruptly. With no code left to run, the thread has completed execution. The {@link + * #isAlive isAlive} method can be used to test if a started thread has terminated. + * The {@link #join() join} method can be used to wait for a thread to terminate. * *

Threads have a unique {@linkplain #threadId() identifier} and a {@linkplain * #getName() name}. The identifier is generated when a {@code Thread} is created @@ -79,7 +80,7 @@ * {@code Thread} supports a special inheritable thread local for the thread * {@linkplain #getContextClassLoader() context-class-loader}. * - *

Platform threads

+ *

Platform Threads

*

{@code Thread} supports the creation of platform threads that are * typically mapped 1:1 to kernel threads scheduled by the operating system. * Platform threads will usually have a large stack and other resources that are @@ -99,7 +100,7 @@ * #getPriority() thread priority} and are members of a {@linkplain ThreadGroup * thread group}. * - *

Virtual threads

+ *

Virtual Threads

*

{@code Thread} also supports the creation of virtual threads. * Virtual threads are typically user-mode threads scheduled by the Java * runtime rather than the operating system. Virtual threads will typically require @@ -124,7 +125,7 @@ * Virtual threads have a fixed {@linkplain #getPriority() thread priority} * that cannot be changed. * - *

Creating and starting threads

+ *

Creating and Starting Threads

* *

{@code Thread} defines public constructors for creating platform threads and * the {@link #start() start} method to schedule threads to execute. {@code Thread} @@ -153,7 +154,7 @@ * ThreadFactory factory = Thread.ofVirtual().factory(); * } * - *

Inheritance when creating threads

+ *

Inheritance When Creating Threads

* A {@code Thread} created with one of the public constructors inherits the daemon * status and thread priority from the parent thread at the time that the child {@code * Thread} is created. The {@linkplain ThreadGroup thread group} is also inherited when @@ -171,7 +172,38 @@ * {@link Builder#inheritInheritableThreadLocals(boolean) inheritInheritableThreadLocals} * method can be used to select if the initial values are inherited. * - *

Unless otherwise specified, passing a {@code null} argument to a constructor + *

Thread Interruption

+ * A {@code Thread} has an interrupted status that serves as a "request" for + * code executing in the thread to "cancel or stop what it is doing". The interrupted + * status is set by invoking the target thread's {@link #interrupt()} method. + * {@link #sleep(long) Thread.sleep(long)}, {@link Object#wait() Object.wait()} and + * many other blocking methods detect the thread's interrupted status is set and cause the + * thread to return early from the blocking method by throwing an exception. + * + *

Blocking methods that throw {@link InterruptedException} do so after first clearing + * the interrupted status. Code that catches {@code InterruptedException} should rethrow + * the exception, or reset the current thread's interrupted status before it + * continues normally or handles it by throwing another type of exception. The + * current thread's interrupted status is reset by interrupting the current thread with + * {@link Thread#currentThread() Thread.currentThread()}.{@link #interrupt() interrupt()}. + * + *

Some blocking methods are specified to throw a different exception or return normally + * when interrupted. Blocking I/O operations on an {@link java.nio.channels.InterruptibleChannel} + * close the channel and throw {@link java.nio.channels.ClosedByInterruptException} with + * the interrupted status set. A thread blocked in a {@link java.nio.channels.Selector} + * will return immediately if interrupted, with the interrupted status set. + * + *

Code that doesn't block but needs to detect interruption can poll the + * current thread's interrupted status using + * {@link Thread#currentThread() Thread.currentThread()}.{@link #isInterrupted() isInterrupted()}. + * + *

In addition to the {@link #interrupt()} and {@link #isInterrupted()} methods, + * {@code Thread} also defines the static {@link #interrupted() Thread.interrupted()} + * method to test the current thread's interrupted status and clear it. It should be rare + * to need to use this method. + * + *

Null Handling

+ * Unless otherwise specified, passing a {@code null} argument to a constructor * or method in this class will cause a {@link NullPointerException} to be thrown. * * @implNote @@ -190,8 +222,9 @@ * * {@systemProperty jdk.virtualThreadScheduler.parallelism} * - * The number of platform threads available for scheduling virtual - * threads. It defaults to the number of available processors. + * The scheduler's target parallelism. This is the number of platform threads + * available for scheduling virtual threads. It defaults to the number of available + * processors. * * * @@ -202,9 +235,13 @@ * * * + *

The virtual thread scheduler can be monitored and managed with the + * {@link jdk.management/jdk.management.VirtualThreadSchedulerMXBean} management + * interface. * * @since 1.0 */ +@SuppressWarnings("doclint:reference") // cross-module links public class Thread implements Runnable { /* Make sure registerNatives is the first thing does. */ private static native void registerNatives(); @@ -1558,6 +1595,9 @@ private void exit() { * @implNote In the JDK Reference Implementation, interruption of a thread * that is not alive still records that the interrupt request was made and * will report it via {@link #interrupted()} and {@link #isInterrupted()}. + * + * @see ##thread-interruption Thread Interruption + * @see #isInterrupted() */ public void interrupt() { // Setting the interrupted status must be done before reading nioBlocker. @@ -1589,6 +1629,7 @@ public void interrupt() { * * @return {@code true} if the current thread has been interrupted; * {@code false} otherwise. + * @see ##thread-interruption Thread Interruption * @see #isInterrupted() */ public static boolean interrupted() { @@ -1601,7 +1642,8 @@ public static boolean interrupted() { * * @return {@code true} if this thread has been interrupted; * {@code false} otherwise. - * @see #interrupted() + * @see ##thread-interruption Thread Interruption + * @see #interrupt() */ public boolean isInterrupted() { return interrupted; From 5e7d13e3001f3a821c8cdce13b56a82e6bbb2bdc Mon Sep 17 00:00:00 2001 From: Alan Bateman Date: Thu, 6 Nov 2025 09:21:47 +0000 Subject: [PATCH 2/7] Improve wording --- .../share/classes/java/lang/InterruptedException.java | 8 ++++---- src/java.base/share/classes/java/lang/Thread.java | 7 +++---- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/java.base/share/classes/java/lang/InterruptedException.java b/src/java.base/share/classes/java/lang/InterruptedException.java index 6108392ebc85b..51a73ce5995f9 100644 --- a/src/java.base/share/classes/java/lang/InterruptedException.java +++ b/src/java.base/share/classes/java/lang/InterruptedException.java @@ -32,10 +32,10 @@ * *

Blocking methods that throw {@code InterruptedException} clear the thread's * interrupted status before throwing the exception. Code that catches {@code - * InterruptedException} should rethrow the exception, or reset the current thread's - * interrupted status, with {@link Thread#currentThread() Thread.currentThread()}. - * {@link Thread#interrupt() interrupt()}, before it continues normally or handles the - * exception by throwing another type of exception. + * InterruptedException} should rethrow the exception, or restore the current thread's + * interrupted status, with + * {@link Thread#currentThread() Thread.currentThread()}.{@link Thread#interrupt() interrupt()}, + * before continuing normally or handling it by throwing another type of exception. * * @author Frank Yellin * @see Thread##thread-interruption Thread Interruption diff --git a/src/java.base/share/classes/java/lang/Thread.java b/src/java.base/share/classes/java/lang/Thread.java index 9e68ee30f3d5e..d83c8bb8fbdd7 100644 --- a/src/java.base/share/classes/java/lang/Thread.java +++ b/src/java.base/share/classes/java/lang/Thread.java @@ -182,10 +182,9 @@ * *

Blocking methods that throw {@link InterruptedException} do so after first clearing * the interrupted status. Code that catches {@code InterruptedException} should rethrow - * the exception, or reset the current thread's interrupted status before it - * continues normally or handles it by throwing another type of exception. The - * current thread's interrupted status is reset by interrupting the current thread with - * {@link Thread#currentThread() Thread.currentThread()}.{@link #interrupt() interrupt()}. + * the exception, or restore the current thread's interrupted status, with + * {@link #currentThread() Thread.currentThread()}.{@link #interrupt()}, before continuing + * normally or handling it by throwing another type of exception. * *

Some blocking methods are specified to throw a different exception or return normally * when interrupted. Blocking I/O operations on an {@link java.nio.channels.InterruptibleChannel} From e96a3b58b1a4fbf3861192d89cb7f87a4f50ee91 Mon Sep 17 00:00:00 2001 From: Alan Bateman Date: Thu, 6 Nov 2025 12:59:54 +0000 Subject: [PATCH 3/7] More wordsmithing --- .../share/classes/java/lang/Thread.java | 35 ++++++++++--------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/src/java.base/share/classes/java/lang/Thread.java b/src/java.base/share/classes/java/lang/Thread.java index d83c8bb8fbdd7..916e2a9834a0e 100644 --- a/src/java.base/share/classes/java/lang/Thread.java +++ b/src/java.base/share/classes/java/lang/Thread.java @@ -173,27 +173,30 @@ * method can be used to select if the initial values are inherited. * *

Thread Interruption

- * A {@code Thread} has an interrupted status that serves as a "request" for - * code executing in the thread to "cancel or stop what it is doing". The interrupted - * status is set by invoking the target thread's {@link #interrupt()} method. - * {@link #sleep(long) Thread.sleep(long)}, {@link Object#wait() Object.wait()} and - * many other blocking methods detect the thread's interrupted status is set and cause the - * thread to return early from the blocking method by throwing an exception. + * A {@code Thread} has an interrupted status which serves as a "request" for + * code executing in the thread to "stop or cancel its current activity". The interrupted + * status is set by invoking the target thread's {@link #interrupt()} method. Many methods + * that cause a thread to block or wait are interruptible, meaning they detect + * that the thread's interrupted status is set and cause execution to return early from + * the method, usually by throwing an exception. * - *

Blocking methods that throw {@link InterruptedException} do so after first clearing - * the interrupted status. Code that catches {@code InterruptedException} should rethrow - * the exception, or restore the current thread's interrupted status, with + *

If a thread executing {@link #sleep(long) Thread.sleep} or {@link Object#wait() + * Object.wait} is interrupted then it causes the method to return early and throw + * {@link InterruptedException}. Methods that throw {@code InterruptedException} do so after + * first clearing the interrupted status. Code that catches {@code InterruptedException} + * should rethrow the exception, or restore the current thread's interrupted status, with * {@link #currentThread() Thread.currentThread()}.{@link #interrupt()}, before continuing * normally or handling it by throwing another type of exception. * - *

Some blocking methods are specified to throw a different exception or return normally - * when interrupted. Blocking I/O operations on an {@link java.nio.channels.InterruptibleChannel} - * close the channel and throw {@link java.nio.channels.ClosedByInterruptException} with - * the interrupted status set. A thread blocked in a {@link java.nio.channels.Selector} - * will return immediately if interrupted, with the interrupted status set. + *

If a thread executing a blocking I/O operation on an {@link + * java.nio.channels.InterruptibleChannel} is interrupted then it causes the channel to be + * closed, and the blocking I/O operation to throw {@link java.nio.channels.ClosedByInterruptException} + * with the thread's interrupted status set. If a thread is blocked in a {@linkplain + * java.nio.channels.Selector selection operation} is interrupted then it causes the + * selection operation to return early, with the thread's interrupted status set. * - *

Code that doesn't block but needs to detect interruption can poll the - * current thread's interrupted status using + *

Code that doesn't invoke any interruptible methods can still respond to interrupt + * by polling the current thread's interrupt status with * {@link Thread#currentThread() Thread.currentThread()}.{@link #isInterrupted() isInterrupted()}. * *

In addition to the {@link #interrupt()} and {@link #isInterrupted()} methods, From 90a48ca3dbd22f0d9818d9c34d5527fa032e245e Mon Sep 17 00:00:00 2001 From: Alan Bateman Date: Mon, 10 Nov 2025 20:15:22 +0000 Subject: [PATCH 4/7] Improve javadoc, add apiNote to interrupted() --- .../share/classes/java/lang/Thread.java | 25 ++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/java.base/share/classes/java/lang/Thread.java b/src/java.base/share/classes/java/lang/Thread.java index 916e2a9834a0e..e81dc8e10d297 100644 --- a/src/java.base/share/classes/java/lang/Thread.java +++ b/src/java.base/share/classes/java/lang/Thread.java @@ -181,12 +181,15 @@ * the method, usually by throwing an exception. * *

If a thread executing {@link #sleep(long) Thread.sleep} or {@link Object#wait() - * Object.wait} is interrupted then it causes the method to return early and throw - * {@link InterruptedException}. Methods that throw {@code InterruptedException} do so after - * first clearing the interrupted status. Code that catches {@code InterruptedException} - * should rethrow the exception, or restore the current thread's interrupted status, with - * {@link #currentThread() Thread.currentThread()}.{@link #interrupt()}, before continuing - * normally or handling it by throwing another type of exception. + * Object.wait} is interrupted then it causes the method to exit and throw + * {@link InterruptedException}. Methods that throw {@code InterruptedException} do + * so after first clearing the interrupted status. Code that catches {@code + * InterruptedException} should rethrow the exception, or restore the current thread's + * interrupted status, with {@link #currentThread() Thread.currentThread()}.{@link #interrupt()}, + * before continuing normally or handling it by throwing another type of exception. + * Code that throws a different type of exception with the {@code InterruptedException} + * as {@linkplain Throwable#getCause() cause} should also restore the interrupted + * status before throwing the exception. * *

If a thread executing a blocking I/O operation on an {@link * java.nio.channels.InterruptibleChannel} is interrupted then it causes the channel to be @@ -1629,6 +1632,16 @@ public void interrupt() { * interrupted again, after the first call had cleared its interrupted * status and before the second call had examined it). * + * @apiNote It should be rare to use this method directly. It is intended + * for cases that detect {@linkplain ##thread-interruption thread interruption} + * and clear the interrupted status before throwing {@link InterruptedException}. + * It is also intended for cases that implement an uninterruptible + * method that makes use of an interruptible method such as + * {@link LockSupport#park()}. The {@code interrupted()} method can be used + * to test if interrupted and clear the interrupted status to allow the code + * retry the interruptible method. The uninterruptible method + * should restore the interrupted status before it completes. + * * @return {@code true} if the current thread has been interrupted; * {@code false} otherwise. * @see ##thread-interruption Thread Interruption From cfba1f26dcddeae7a56d4b392eadbca83abe3732 Mon Sep 17 00:00:00 2001 From: Alan Bateman Date: Tue, 11 Nov 2025 07:31:39 +0000 Subject: [PATCH 5/7] More word smithing, drop link to VirtualThreadSchedulerMXBean --- .../java/lang/InterruptedException.java | 9 ++++++--- .../share/classes/java/lang/Thread.java | 20 +++++++++---------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/java.base/share/classes/java/lang/InterruptedException.java b/src/java.base/share/classes/java/lang/InterruptedException.java index 51a73ce5995f9..b23811b126792 100644 --- a/src/java.base/share/classes/java/lang/InterruptedException.java +++ b/src/java.base/share/classes/java/lang/InterruptedException.java @@ -33,9 +33,12 @@ *

Blocking methods that throw {@code InterruptedException} clear the thread's * interrupted status before throwing the exception. Code that catches {@code * InterruptedException} should rethrow the exception, or restore the current thread's - * interrupted status, with - * {@link Thread#currentThread() Thread.currentThread()}.{@link Thread#interrupt() interrupt()}, - * before continuing normally or handling it by throwing another type of exception. + * interrupted status, with {@link Thread#currentThread() + * Thread.currentThread()}.{@link Thread#interrupt() interrupt()}, before continuing + * normally or handling it by throwing another type of exception. Code that throws a + * different type of exception with the {@code InterruptedException} as {@linkplain + * Throwable#getCause() cause} should also restore the interrupted status before + * throwing the exception. * * @author Frank Yellin * @see Thread##thread-interruption Thread Interruption diff --git a/src/java.base/share/classes/java/lang/Thread.java b/src/java.base/share/classes/java/lang/Thread.java index e81dc8e10d297..35d9abd90a64f 100644 --- a/src/java.base/share/classes/java/lang/Thread.java +++ b/src/java.base/share/classes/java/lang/Thread.java @@ -125,7 +125,7 @@ * Virtual threads have a fixed {@linkplain #getPriority() thread priority} * that cannot be changed. * - *

Creating and Starting Threads

+ *

Creating And Starting Threads

* *

{@code Thread} defines public constructors for creating platform threads and * the {@link #start() start} method to schedule threads to execute. {@code Thread} @@ -181,12 +181,12 @@ * the method, usually by throwing an exception. * *

If a thread executing {@link #sleep(long) Thread.sleep} or {@link Object#wait() - * Object.wait} is interrupted then it causes the method to exit and throw - * {@link InterruptedException}. Methods that throw {@code InterruptedException} do - * so after first clearing the interrupted status. Code that catches {@code - * InterruptedException} should rethrow the exception, or restore the current thread's - * interrupted status, with {@link #currentThread() Thread.currentThread()}.{@link #interrupt()}, - * before continuing normally or handling it by throwing another type of exception. + * Object.wait} is interrupted then it causes the method to throw {@link InterruptedException}. + * Methods that throw {@code InterruptedException} do so after first clearing the + * interrupted status. Code that catches {@code InterruptedException} should rethrow the + * exception, or restore the current thread's interrupted status, with + * {@link #currentThread() Thread.currentThread()}.{@link #interrupt()}, before + * continuing normally or handling it by throwing another type of exception. * Code that throws a different type of exception with the {@code InterruptedException} * as {@linkplain Throwable#getCause() cause} should also restore the interrupted * status before throwing the exception. @@ -241,12 +241,10 @@ * * *

The virtual thread scheduler can be monitored and managed with the - * {@link jdk.management/jdk.management.VirtualThreadSchedulerMXBean} management - * interface. + * {@code jdk.management.VirtualThreadSchedulerMXBean} management interface. * * @since 1.0 */ -@SuppressWarnings("doclint:reference") // cross-module links public class Thread implements Runnable { /* Make sure registerNatives is the first thing does. */ private static native void registerNatives(); @@ -1635,7 +1633,7 @@ public void interrupt() { * @apiNote It should be rare to use this method directly. It is intended * for cases that detect {@linkplain ##thread-interruption thread interruption} * and clear the interrupted status before throwing {@link InterruptedException}. - * It is also intended for cases that implement an uninterruptible + * It may also be useful for cases that implement an uninterruptible * method that makes use of an interruptible method such as * {@link LockSupport#park()}. The {@code interrupted()} method can be used * to test if interrupted and clear the interrupted status to allow the code From fd1640959c1b13950ae0a59a4faeb1eac63b36e7 Mon Sep 17 00:00:00 2001 From: Alan Bateman Date: Tue, 11 Nov 2025 18:27:02 +0000 Subject: [PATCH 6/7] Word smithing, mention throwing with IE as suppressed exception --- .../share/classes/java/lang/InterruptedException.java | 9 +++------ src/java.base/share/classes/java/lang/Thread.java | 11 ++++++----- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/java.base/share/classes/java/lang/InterruptedException.java b/src/java.base/share/classes/java/lang/InterruptedException.java index b23811b126792..e8cf3d28bc590 100644 --- a/src/java.base/share/classes/java/lang/InterruptedException.java +++ b/src/java.base/share/classes/java/lang/InterruptedException.java @@ -27,18 +27,15 @@ /** * Thrown when a thread executing a blocking method is {@linkplain Thread#interrupt() - * interrupted}. {@link Thread#sleep(long)}, {@link Object#wait()} and many other - * blocking methods throw this exception if interrupted. + * interrupted}. {@link Thread#sleep(long) Thread.sleep}, {@link Object#wait() + * Object.wait} and many other blocking methods throw this exception if interrupted. * *

Blocking methods that throw {@code InterruptedException} clear the thread's * interrupted status before throwing the exception. Code that catches {@code * InterruptedException} should rethrow the exception, or restore the current thread's * interrupted status, with {@link Thread#currentThread() * Thread.currentThread()}.{@link Thread#interrupt() interrupt()}, before continuing - * normally or handling it by throwing another type of exception. Code that throws a - * different type of exception with the {@code InterruptedException} as {@linkplain - * Throwable#getCause() cause} should also restore the interrupted status before - * throwing the exception. + * normally or handling it by throwing another type of exception. * * @author Frank Yellin * @see Thread##thread-interruption Thread Interruption diff --git a/src/java.base/share/classes/java/lang/Thread.java b/src/java.base/share/classes/java/lang/Thread.java index 35d9abd90a64f..fddc579e2b773 100644 --- a/src/java.base/share/classes/java/lang/Thread.java +++ b/src/java.base/share/classes/java/lang/Thread.java @@ -186,15 +186,16 @@ * interrupted status. Code that catches {@code InterruptedException} should rethrow the * exception, or restore the current thread's interrupted status, with * {@link #currentThread() Thread.currentThread()}.{@link #interrupt()}, before - * continuing normally or handling it by throwing another type of exception. - * Code that throws a different type of exception with the {@code InterruptedException} - * as {@linkplain Throwable#getCause() cause} should also restore the interrupted - * status before throwing the exception. + * continuing normally or handling it by throwing another type of exception. Code that + * throws another type of exception with the {@code InterruptedException} as {@linkplain + * Throwable#getCause() cause}, or the {@code InterruptedException} as a {@linkplain + * Throwable#addSuppressed(Throwable) suppressed exception}, should also restore the + * interrupted status before throwing the exception. * *

If a thread executing a blocking I/O operation on an {@link * java.nio.channels.InterruptibleChannel} is interrupted then it causes the channel to be * closed, and the blocking I/O operation to throw {@link java.nio.channels.ClosedByInterruptException} - * with the thread's interrupted status set. If a thread is blocked in a {@linkplain + * with the thread's interrupted status set. If a thread blocked in a {@linkplain * java.nio.channels.Selector selection operation} is interrupted then it causes the * selection operation to return early, with the thread's interrupted status set. * From 48a6f22aca77b162f1b6275ffc61d844a6955661 Mon Sep 17 00:00:00 2001 From: Alan Bateman Date: Tue, 11 Nov 2025 18:29:08 +0000 Subject: [PATCH 7/7] interrupt status -> interrupted status --- src/java.base/share/classes/java/lang/Thread.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/java.base/share/classes/java/lang/Thread.java b/src/java.base/share/classes/java/lang/Thread.java index fddc579e2b773..798ded2b9410c 100644 --- a/src/java.base/share/classes/java/lang/Thread.java +++ b/src/java.base/share/classes/java/lang/Thread.java @@ -200,8 +200,9 @@ * selection operation to return early, with the thread's interrupted status set. * *

Code that doesn't invoke any interruptible methods can still respond to interrupt - * by polling the current thread's interrupt status with - * {@link Thread#currentThread() Thread.currentThread()}.{@link #isInterrupted() isInterrupted()}. + * by polling the current thread's interrupted status with + * {@link Thread#currentThread() Thread.currentThread()}.{@link #isInterrupted() + * isInterrupted()}. * *

In addition to the {@link #interrupt()} and {@link #isInterrupted()} methods, * {@code Thread} also defines the static {@link #interrupted() Thread.interrupted()}