On Fri, 15 Apr 2022 11:45:01 GMT, Alan Bateman <[email protected]> wrote:
>> This is the implementation of JEP 425: Virtual Threads (Preview); TBD which
>> JDK version to target.
>>
>> We will refresh this PR periodically to pick up changes and fixes from the
>> loom repo.
>>
>> Most of the new mechanisms in the HotSpot VM are disabled by default and
>> require running with `--enable-preview` to enable.
>>
>> The patch has support for x64 and aarch64 on the usual operating systems
>> (Linux, macOS, and Windows). There are stubs (calling Unimplemented) for
>> zero and some of the other ports. Additional ports can be contributed via
>> PRs against the fibers branch in the loom repo.
>>
>> There are changes in many areas. To reduce notifications/mails, the labels
>> have been trimmed down for now to hotspot, serviceability and core-libs.
>> We'll add the complete set of labels when the PR is further along.
>>
>> The changes include a refresh of java.util.concurrent and ForkJoinPool from
>> Doug Lea's CVS. These changes will probably be proposed and integrated in
>> advance of this PR.
>>
>> The changes include some non-exposed and low-level infrastructure to support
>> the (in draft) JEPs for Structured Concurrency and Scope Locals. This is to
>> make life a bit easier and avoid having to separate VM changes and juggle
>> branches at this time.
>
> 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 five additional
> commits since the last revision:
>
> - Refresh
> - Refresh
> - Merge with jdk-19+18
> - Refresh
> - Initial push
src/java.base/share/classes/java/lang/Thread.java line 1554:
> 1552: * Null out reference after Thread termination (JDK-4006245)
> 1553: */
> 1554: void clearReferences() {
I had a look at the referenced
[JDK-4006245](https://bugs.openjdk.java.net/browse/JDK-4006245). The
previous/existing reference cleaning logic seems to have been added mainly to
`null` the reference to the user/application class instance represented by the
`Runnable` task. Of course, other references too were being cleared. The
description in the linked JBS seems to suggest that the `Thread` instance
wasn't being GCed sooner. That was more than 2 decades back. I don't have
enough knowledge of this area to know if this is still an issue in recent GC
implementations.
With the new implementation in this PR, this `clearReferences()` will no longer
set the user/application `task` instance to `null`. I understand why we aren't
doing that - the `task` field in the `FieldHolder` is `final` (IMO, rightly
so). This, in theory, undoes what JDK-4006245 had implemented. I don't know if
we still need such a change here and I'm just bringing this up to see if anyone
else has any opinions or if any additional experiments need to be run in
context of this change.
-------------
PR: https://git.openjdk.java.net/jdk/pull/8166