Single Thread Continuation

Andrew Haley aph-open at littlepinkcloud.com
Sun Jul 2 10:38:28 UTC 2023


On 7/2/23 10:07, Øystein Myhre Andersen wrote:
> I think I remember that it was mentioned a while ago that Continuation
> will perhaps be introduced again in a 'single thread' version.
> 
> This is what I need to implement Quasi Parallel systems in Simula
> <https://portablesimula.github.io/github.io/>.
> 
> Now I use virtual threads and semaphore to achieve the same. But it
> seems a bit exaggerated when I know that Continuation is in the
> background.
> 
> Anyone know anything about this ?

There are some particular problems with exposing Continuation. In particular,
Java has a hard guarantee that Thread.currentThread() return the current Thread,
and that the current Thread never changes, even when a virtual thread is re-
mounted on a different carrier thread.

Having said that, there is a (fairly long-term) plan for user-defined virtual
thread schedulers, but it'll be a while.

Rather than wait for any of that, using LockSupport.park() and unpark(), or indeed
Semaphores, for detach and resume is a fine thing to do.

-- 
Andrew Haley  (he/him)
Java Platform Lead Engineer
Red Hat UK Ltd. <https://www.redhat.com>
https://keybase.io/andrewhaley
EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671



More information about the loom-dev mailing list