Detailed explanation of Thread.yield() method

The Thread.yield() method in Java thread is translated as thread concession. As the name implies, when a thread uses this method, it will give up its CPU execution time and let itself or other threads run. Note that it is to allow itself or other threads to run, not simply to other threads. .
The function of yield() is to yield. It allows the current thread "running state" into a "ready state", so that other waiting threads with the same priority access to executive power; however, does not guarantee
after the certificate in the current thread calls yield (), the other with the same priority The thread of the first level must be able to obtain the right to execute; it is also possible that the current thread enters the "running state" to continue running!

Guess you like

Origin blog.csdn.net/weixin_38019299/article/details/107711243
Recommended