Java – wait(), notify() – which thread is unlocked first?
•
Java
Try to understand wait() and notify() I know when thread a enters wait (). It will be awakened by notify () from other threads
But what happens if threads a, B, c enter wait () in the order represented? Who will be awakened by notify()? According to my experiment, a thread will be awakened first Am I right?
Does this mean that the system knows the order in which threads enter wait()?
Solution
From the document of notify (), emphasize my:
Other APIs (such as semaphore) have the concept of "fairness", so you can ensure that threads continue in the order they block
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码