On Thu, 29 May 2025 21:18:03 GMT, Leonid Mesnik <lmes...@openjdk.org> wrote:

>> Since there is only one writer thread, volatile should be sufficient. The 
>> only requirement is to make writes visible to the reader thread. volatile 
>> accomplishes that.
>
> Thanks for explanation. Can you please add corresponding comment. The 
> volatile counters are rare thing...

I think the evaluation is not correct (lack of synchronization is an issue too).
main thread also writes the value and I think this is the problem here.
Look at line 148 - it resets `counter1` instead of `counter2` and this happens 
after the test sends `COMMAND_TEST1`. So if listener thread already handled 
caught exception, we get the failure.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/25236#discussion_r2114790682

Reply via email to