Let's say I want to βpauseβ a thread so that other threads can work more efficiently. What is the minimum sleep period before blocking, becomes meaningless (or almost meaningless)?
I would expect that any amount of sleep will at least be the functional equivalent of a call yield(), so there is never a point where it is "pointless". There is definitely a point where small values ββare substantially indistinguishable, because the overhead of waiting for the operating system to return to your thread is more than a short sleep time. This probably happens somewhere in the range of 5-10, but, of course, it will be OS-specific.
yield()
This is difficult to generalize and will depend on your specific problem. But I would not sleep on my own to control the flows. You can put threads in Executorand let them control them. You can also use PriorityQueue to accomplish your tasks.
Executor
IIRC Thread.sleep(0) , , .
... , Thread.sleep .
, , , , . , , , Thread.sleep, .
Source: https://habr.com/ru/post/1740200/More articles:Displaying the same webpage on multiple screens - c #How to save dynamic data changes in server cache? - c #Opening a specific file with a batch file? - fileIs there any software tool to convert "any type of file" to a TIFF image? - toolkitHow to get a GWT console / development mode to generate css errors? - cssFailed to set Rails session cookie - ruby ββ| fooobar.comPHP: Shorten the URL by cutting it off the center? - phpHow to get regex length in vim? - vimajaxify multipart encoded form (download forms) - javascriptLINQ: converting an array [,] to an array [] - c #All Articles