Can't yield from within an instance created by reflection
Alan Bateman
Alan.Bateman at oracle.com
Wed Apr 7 09:16:55 UTC 2021
On 07/04/2021 09:57, Øystein Myhre Andersen wrote:
> Is there a limit to the number of virtual threads ?
> The error in my implementation of class Simulation occurs when I start
> virtual thread number 257.
> Is this just a coincidence or ....
Virtual threads are just objects in the heap and 1M virtual threads
shouldn't be an issue. I suspect David is right that you've got threads
pinned due to Java monitors and synchronization (you also mentioned
"oversynchronization" in one of your mails). The scheduler is based on
ForkJoinPool and it's setup to spin up additional underlying carrier
threads to help when there are virtual threads blocked in Object.wait.
The default maximum is 256. Can you say a bit more about the locking
that you are using when the Simula coroutines are implemented with
threads? Would it be hard to convert it to use java.util.concurrent locks?
-Alan
More information about the loom-dev
mailing list