On Mon, 17 Jun 2024 13:24:23 GMT, Inigo Mediavilla Saiz <d...@openjdk.org> 
wrote:

>> Follow up to https://github.com/openjdk/jdk/pull/19482 that was causing 
>> issues when the PrintMountedVirtualTest.java was
>> running with `JTREG_TEST_THREAD_FACTORY=Virtual` in the loom repo. 
>> 
>> - Fixes issues where the test observes the thread during transitions.
>> - Fixes a potential issue in the test where CountDownLatch.countDown unparks 
>> the main (virtual) thread and the main thread observes the dummy thread is 
>> transition .
>
> Inigo Mediavilla Saiz has updated the pull request incrementally with one 
> additional commit since the last revision:
> 
>   Improve assert and document conditional print

I looked at the changes in the latest revision (9a954efe) and they look okay, 
it basically skips printing the mounted virtual thread when that virtual thread 
is interacting with the scheduler or timer mechanism, the so called "temporary 
transitions" that are needed to ensure the correct identity when submitting 
tasks to the scheduler, and to avoid deadlock when submitting tasks to the 
scheduler requires locking. It also changes the test so testing with 
JTREG_TEST_THREAD_FACTORY=Virtual won't observe the dummy thread in a temporary 
transition.

We can improve on this in the loom repo as JavaThread has the thread ID of the 
mounted virtual thread. Note that the pre-existing "Carrying ..." line has the 
same issue as we've been discussing here, it just hasn't been noticed perhaps.

One thing that I think we should do is remove the thread name from the "Mounted 
..." line. I initially thought this was a good idea but there is no reference 
to this when a virtual thread is mounted and interacting with the scheduler. 
Virtual threads don't have a name by default so it's not a big a loss as you 
might think. We can of course re-visit this in the future.

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

PR Comment: https://git.openjdk.org/jdk/pull/19744#issuecomment-2175840976

Reply via email to