Hacker News new | ask | show | jobs
by pron 2149 days ago
I wouldn't use virtual threads for long-running, compute-heavy tasks, because even when we expose forced preemption, it might not be as efficient as a kernel preemption. Also, if you run a lot of native (non-Java) code that blocks -- or that upcalls back into Java and then blocks -- then the underlying "carrier" kernel thread will be blocked, and if this happens a lot, it can impact other virtual threads that share the same scheduler. So for compute-heavy jobs and for code that blocks in native or upcalls to Java, the platform threads would be more appropriate.