3 ms·
Is this why java.lang.Thread still has the yield() method? All Java SE implementations I've ever seen use (preemptive) OS threads, so I assumed it's been this
by grishka 6y ago
Is this why java.lang.Thread still has the yield() method?
All Java SE implementations I've ever seen use (preemptive) OS threads, so I assumed it's been this way from the beginning, and this yield() never made much sense to me.
- touisteur 6y agoGiving a chance to threads/processes with the same priority to be scheduled without doing any I/O or syscall? Used this once.
- varjag 6y agoIIRC Java didn't support native threads until 1997 or so.
- Matthias247 6y agoIt still makes sense if you implement spinlocks and other lock free datastructures yourself and want to give other threads a chance to run. But that’s more of an expert use-case - typical libraries and applications shouldn’t use it.