RFR: 8370568: Refer to Thread.interrupted as "interrupted status" consistently

Alan Bateman alanb at openjdk.org
Tue Oct 28 07:52:03 UTC 2025


On Fri, 24 Oct 2025 09:45:38 GMT, Pavel Rappo <prappo at openjdk.org> wrote:

> Throughout documentation and source code, the `Thread.interrupted` flag is referred to as either "interrupt**ed** status" or "interrupt status". It might be good to be consistent.
> 
> Historically, it seems to have initially been "interrupted status". This is how the flag is called in `java.lang.Thread` and the "Java Concurrency in Practice" book. ("The Java Programming Language" calls it "interrupted **state**".) However, over the years "interrupt status" appeared in documentation and source code through networking and NIO classes.

I skimmed through the replace and it looks okay. There are several places where we should be linking as "interrupted status" will look like a grammatical error with the change. We do that as needed, not this PR.

This is the first update to some of these files in 2025 so you will need to update the copyright header of those files.

src/java.base/share/classes/java/net/DatagramSocket.java line 614:

> 612:      *        interrupting a thread receiving a datagram packet will close the
> 613:      *        underlying channel and cause this method to throw {@link
> 614:      *        java.nio.channels.ClosedByInterruptException} with the interrupted

Can you change this to "the thread's interrupted status set"?

src/java.base/share/classes/java/net/DatagramSocket.java line 620:

> 618:      *        datagram packet. In that case, interrupting the virtual thread will
> 619:      *        cause it to wakeup and close the socket. This method will then throw
> 620:      *        {@code SocketException} with the interrupted status set.

Same thing here, and in ServerSocket and Socket.

test/jdk/java/lang/Thread/virtual/CustomScheduler.java line 207:

> 205: 
> 206:     /**
> 207:      * Test running task with the carrier interrupted status set.

We can change this to "the carrier's interrupted status set".

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

Marked as reviewed by alanb (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/27972#pullrequestreview-3387081610
PR Review Comment: https://git.openjdk.org/jdk/pull/27972#discussion_r2468253205
PR Review Comment: https://git.openjdk.org/jdk/pull/27972#discussion_r2468257078
PR Review Comment: https://git.openjdk.org/jdk/pull/27972#discussion_r2468273763


More information about the hotspot-gc-dev mailing list