3 ms·
Sleep 0 sounds like quite a hack, Go has the neater https://pkg.go.dev/runtime#Gosched https://pkg.go.dev/runtime#Gosched instead, and I assume there will be a
by sudhirj 5y ago
Sleep 0 sounds like quite a hack, Go has the neater https://pkg.go.dev/runtime#Gosched https://pkg.go.dev/runtime#Gosched instead, and I assume there will be a Java equivalent as well. And if most stdlib methods and all blocking methods call it, it's going to be pretty difficult to hang a green thread.
- WatchDog 5y agoFWIW, Java has had `Thread#yield()`[0] since inception. [0]: https://docs.oracle.com/javase/7/docs/api/java/lang/Thread.html#yield https://docs.oracle.com/javase/7/docs/api/java/lang/Thread.h...()
- kaba0 5y agoSince there is a runtime that knows everything about the state of the thread, my understanding is that there is no need for explicit yields. Everything will turn automagically into non-blocking (except for FFI)