On Tue, 7 Feb 2023 01:49:39 GMT, Serguei Spitsyn <sspit...@openjdk.org> wrote:

>> test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod011t.java
>>  line 94:
>> 
>>> 92:         while(!doExit) {
>>> 93:             l--; l++;
>>> 94:             Thread.currentThread().sleep(0);
>> 
>> BTW this is an anti-pattern - use `Thread.sleep(n)` - it always applies to 
>> the current thread.
>
> What about replacing sleep(0) with yield()?
> Do we expect it also causing deadlocks? Was it considered?

sleep(0) on a virtual thread ends up doing a tryYield(), which is the same as 
what is done when calling sleep(0), so it should work, although I'm not so sure 
it is any better.

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

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

Reply via email to