When I run the following (simplified) code on a low powered server with only 1 core:
implicit val context: ExecutionContextExecutor = scala.concurrent.ExecutionContext.global
Future(blocking {
while (true) {
java.lang.Thread.sleep(1000)
println("thread 1")
}
})
while (true) {
java.lang.Thread.sleep(1000)
println("main")
}
Only "main" shows up in the logs. If I increase the server to have more cores, then it works. What am I doing wrong? How to make Scala/Java run every thread even when there are limited cores?
My understanding is that the runtime should use some logic to execute one thread for a bit, then switch to the other thread.
scalaVersion := "2.12.12"
After a bit of playing around, I found that if I use ExecutionContext.fromExecutor(Executors.newFixedThreadPool(30))
for my EC it works. So something about the way I understand the global EC & blocking must be wrong.