On Fri, 5 Jan 2024 17:35:01 GMT, Jaikiran Pai <j...@openjdk.org> wrote:

>> In preparation for when virtual threads can unmount while holding a monitor 
>> or unmount when blocking on monitorenter, the implementation of 
>> VirtualThread's interrupt method is refactored to avoid parking/blocking 
>> while holding the Thread's interrupt lock. The implementations of 
>> sun.nio.ch.Interruptible are refactored to close/wakeup the 
>> InterruptibleChannel/Selector after releasing the interrupt lock. There is a 
>> lot of test coverage for async close and interrupt, no additional tests are 
>> added.
>
> src/java.base/share/classes/java/lang/VirtualThread.java line 863:
> 
>> 861:             checkAccess();
>> 862: 
>> 863:             // if current thread is a virtual thread then prevent it 
>> from being
> 
> Is the use of "current thread" here meant to imply "Thread.currentThread()"? 
> If so, is there a check missing for `Thread.currentThread().isVirtual()` here?

It's correct. There are two threads, the current thread that is executing the 
method, plus "this". Serguei is working to change notifyJvmtiDisableSuspend to 
be a static method (JDK-8322744) to make it clearer that it disable suspend of 
the current virtual thread rather than the receiver.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/17219#discussion_r1443170217

Reply via email to