RFR: 8343394: Make MemorySessionImpl.state a stable field [v5]
Quan Anh Mai
qamai at openjdk.org
Tue Nov 5 15:54:33 UTC 2024
On Tue, 5 Nov 2024 15:31:11 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:
>> Okay, fair enough.
>
> Using two blocking queues might also be possible:
> * at the start of each iteration a thread does a `get` on its own queue
> * at the end of each iteration, a thread does a put on the other thread's queue
> * we call put on the first thread's queue, to get things moving
>
> This should create the desired "ping-pong" effect.
There are many ways to achieve this lock-step behaviour. In this case, the operation is extremely fast and there are only 2 threads waiting for each other so I believe a spinlock is the most appropriate. The major benefit of spinning is that we can be more confident that the threads will start each step at the approximately same time, increasing the chance to have a meaningful race.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/21810#discussion_r1829600074
More information about the core-libs-dev
mailing list