Wie fair ist der Object Wait-Pool?

Ullenboom

Bekanntes Mitglied
Nicht spezifiziert. Siehe Spezifikation https://docs.oracle.com/javase/specs/jls/se19/html/jls-17.html#jls-17.2.2:

There is no guarantee about which thread in the wait set is selected. This removal from the wait set enables u's resumption in a wait action. Notice, however, that u's lock actions upon resumption cannot succeed until some time after t fully unlocks the monitor for m.
Das ist einer der Gründe für ReentrantLock(boolean fair), wo man es explizit bestimmen kann.
 

Neue Themen


Oben