During language practice I encounter some strange behaviour.
I've got simple practice code that creates multiple delayed futures, and then wait for completion.
If I use future::join_all everything works fine,but if I try to use mutex and condvar, some futures just didnt processed.
Tinker with it a bit more, update example.
Now it uses fixed pool with 2 threads, first thread will be blocked by loop, but second should process timers without any problem.
It works fine on playground, but locally(8 cores) same code with save rust version just stuck after about half.
Tokio doesn’t expect spawned tasks to block - the default work stealing is around cooperative multitasking: your tasks can spawn more work, and the runtime will manage scheduling them for execution. But, you can’t insert blocking calls that the runtime doesn’t know about, such as mutex acquisitions. If you want to do those, look at tokio_threadpool::blocking - Rust.
I’m pretty sure you can run into a similar issue with FJP - one needs to use ForkJoinPool (Java SE 10 & JDK 10 ) to inform that runtime about a blocking operation.