Question about virtual thread scheduling during a long running task

sam reddy samarendra.kandala at gmail.com
Sat Aug 8 19:44:34 UTC 2020


I am going through the the State of Loom and saw this "Rather, they are
preempted when they block on I/O or synchronization"

my question is if there is loop something like below

long k = 0;
for(long i = 0; i<1000000000000L ; i ++)
{k = k+i;}

Does the virtual thread executing the above code will give processing time
to another virtual thread before completion of the for block. or this
virtual thread will take all the time of underlying OS thread till the for
loop competes? how scheduling works during execution of such loops?

In golang there is  runtime.Gosched() , do we have anything similar to
this?

Please note the above code is an example to illustrate the problem.


Regards
Samarendra


More information about the loom-dev mailing list