What about requiring a ExecutorService instead using GlobalScope indirectly, to allow cancellation/scheduling on Java side?
s
Sam
04/10/2025, 8:09 AM
Interesting suggestion! I figured the CompletableFuture already has you covered for cancellation, but I can see how it might be useful for the consumer to control other things like thread choice. What did you mean by scheduling?
a
Azim Ansari
04/10/2025, 9:58 AM
ScheduledThreadPoolExecutor in java
👍 1
s
suresh
04/10/2025, 8:00 PM
Nice..so on virtual thread (java 21+) isn’t runBlocking a better /simpler solution?
s
Sam
04/11/2025, 7:13 AM
Depends what problem you're trying to solve. When we talk about a thread being blocked we're talking about two problems:
1. The thread is consuming resources/memory but it's not doing any useful work.
2. The thread is prevented from working on other tasks it might be responsible for.
Virtual threads can solve the first problem, but they don't address the second. A single virtual thread can still only do one thing at a time.
Plenty of the reasons for using coroutines fall into the second category rather than the first. And