On Fri, 31 Mar 2023 05:13:04 GMT, Serguei Spitsyn <sspit...@openjdk.org> wrote:

>> So the race I am talking about is between the main thread running 
>> finishThreads() and the launcher thread running startThreads(). The main 
>> thread could execute finishThreads() before the launcher executes 
>> startThreads(). If you comment out the two first sleeps in run_test_cycle() 
>> you can actually see the issue. Again, given that the sleeps are there it is 
>> an unlikely scheduling, but if we want to avoid depending on timing we can 
>> add that extra synchronization.
>
> Sorry, I understood you incorrectly. You are right, there is this kind of 
> race here.
> I've rearranges this area a little bit, and hope, it is cleaner now.
> Now, both `startVirtualThreads()` and `finishVirtualThreads()` are invoked on 
> the main thread, so they do not need to be synchronized any more.  Also, the 
> call to `ensureReady()` are moved to `finishVirtualThreads()` right before 
> the call to `letFinish()`.

Fix looks good, thanks!

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

PR Review Comment: https://git.openjdk.org/jdk/pull/13133#discussion_r1156204813

Reply via email to