Java: waiting on synchronized block, who goes first?

后端 未结 4 1484
青春惊慌失措
青春惊慌失措 2020-12-06 10:30

This question is inspired by this other question.

If multiple threads are waiting on a synchronized block, and the lock becomes available, who goes firs

4条回答
  •  无人及你
    2020-12-06 11:27

    According to this guy: http://tutorials.jenkov.com/java-concurrency/starvation-and-fairness.html

    Java issues no guarantees about the sequence. So I guess it is not based on thread priority

    I'll try to look further for an explanation on how Java actually decides who goes first.

提交回复
热议问题