5 ms·
Unlike go routine, Loom virtual threads are not preempted by the scheduler. I believe you may be able to explicitly preempt a virtual thread but the last time i
by _old_dude_ 5y ago
Unlike go routine, Loom virtual threads are not preempted by the scheduler. I believe you may be able to explicitly preempt a virtual thread but the last time i checked it was not part of the public API
- vips7L 5y agoUnless I'm misunderstanding, virtual threads are preemptive: https://cr.openjdk.java.net/~rpressler/loom/loom/sol1_part1.html https://cr.openjdk.java.net/~rpressler/loom/loom/sol1_part1....
- _old_dude_ 5y agoBy the OS, not by the scheduler see https://cr.openjdk.java.net/~rpressler/loom/loom/sol1_part2.html#forced-preemption https://cr.openjdk.java.net/~rpressler/loom/loom/sol1_part2....
- vips7L 5y agoWhat about pron's comments here then? https://news.ycombinator.com/item?id=27885569 https://news.ycombinator.com/item?id=27885569 > Second, Loom's virtual threads can also be forcibly preempted by the scheduler at any safepoint to implement time sharing
- _old_dude_ 5y agoFor me, preemption by the Java scheduler is not currently supported but may be added in the future, after all the goroutine were not preempted at the beginning in Go. The whole quote > Second, Loom's virtual threads can also be forcibly preempted by the scheduler at any safepoint to implement time sharing. Currently, this capability isn't exposed because we're yet to find a use-case for it I believe it's a reference to [1] but i may be wrong. [1] https://download.java.net/java/early_access/loom/docs/api/java.base/java/lang/Continuation.html#tryPreempt(java.lang.Thread) https://download.java.net/java/early_access/loom/docs/api/ja...
- vips7L 5y ago> The whole quote Sorry I was skimming! Thanks!