Single Thread Continuation

Andrii Lomakin lomakin.andrey at gmail.com
Mon Jul 3 13:31:57 UTC 2023


>
> It would, but if you are correctly synchronized with locks or whatever
> else, then it doesn't matter if you are running on the same carrier thread
> or not. I just simply don't see any case, where code is correct when having
> a single platform thread running multiple VTs is, while it is incorrect
> with multiple carrier threads.


Well if we use long as a state instead of long with atomic operations will
cause the code to be correct in a single carrier and incorrect in the case
of many carriers :-)
If someone wants to go into such subtle optimization.
But putting jokes aside, probably I was wrong in understanding the needs of
the game development area but the main point was that you can work with
complex structures otherwise it would not be possible to use without the
cooperative nature of threads.
And that is quite an interesting case. There are probably not as many game
developers or database developers in the Java world as one might think, but
the number is also not insignificant.


On Mon, Jul 3, 2023 at 3:18 PM Attila Kelemen <attila.kelemen85 at gmail.com>
wrote:

> Andrii Lomakin <lomakin.andrey at gmail.com> ezt írta (időpont: 2023. júl.
> 3., H, 15:13):
>
>> That still seems incorrect to me (in principle, in practice it most
>>> likely will end up to be fine, but I just wouldn't rely on it), because the
>>> barrier is needed to prevent instruction reordering by the compiler, and
>>> you are not safe from that by using the same platform thread.
>>
>>
>> Wouldn't the usage of locks with plain variables instead of
>> atomic/volatile and Thread.park/unpark introduce fences while the
>> cooperative nature of threads would still allow using
>> complex/single-threaded data structures without fear of breaking data
>> consistency because of the absence of risk of another thread seeing
>> incomplete operations?
>>
>>
> It would, but if you are correctly synchronized with locks or whatever
> else, then it doesn't matter if you are running on the same carrier thread
> or not. I just simply don't see any case, where code is correct when having
> a single platform thread running multiple VTs is, while it is incorrect
> with multiple carrier threads.
>


-- 
Best regards,
Andrii Lomakin.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/loom-dev/attachments/20230703/6dedde6f/attachment.htm>


More information about the loom-dev mailing list