RFR: 8378268: Thread.join can wait on Thread, allows joinNanos to be removed [v2]

Alan Bateman alanb at openjdk.org
Thu Feb 26 07:26:15 UTC 2026


> Thread.join was historically implemented with a loop of Object.wait conditioned on isAlive. We couldn't for this virtual threads because it would pin a virtual thread invoking join to it carrier.  Now that Object.wait preempts, it means the special implementation of join for virtual threads can be removed. Where possible, the notifyAll is elided as it adds to the cost of termination.
> 
> The implNote of the join methods is restored (this is implNote text, not spec, so no CSR required).
> 
> Testing: tier1-5

Alan Bateman has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains seven additional commits since the last revision:

 - Remove unused import
 - Merge branch 'master' into JDK-8378268
 - Merge branch 'master' into JDK-8378268
 - Avoid notifyAll if no join
 - Merge branch 'master' into JDK-8378268
 - Merge branch 'master' into JDK-8378268
 - Remove joinNanos

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/29839/files
  - new: https://git.openjdk.org/jdk/pull/29839/files/ffe35246..fa12b57e

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=29839&range=01
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=29839&range=00-01

  Stats: 14260 lines in 479 files changed: 7348 ins; 2653 del; 4259 mod
  Patch: https://git.openjdk.org/jdk/pull/29839.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/29839/head:pull/29839

PR: https://git.openjdk.org/jdk/pull/29839


More information about the core-libs-dev mailing list