When blocking is blocked by multiple threads, in what order do they resume?

Threads A, B, C in this order reach the synchronized method f () in one object.

All have the same priority.

B and C are locked.

A leaves f ().

What thread is now running in f ()? Is it always FIFO B? Or is the order not defined?

If C takes precedence over B, does this guarantee that C will work, not B?

+5
source share
7 answers

The order is undefined. Having a higher priority does not guarantee a first renewal. A higher priority means that the thread receives more processor time during operation, but an implementation is not required to block it.

, , , A-B-C. Java. , , , , , . , , , , FIFO.

+3

, . - , .

+10

, undefined.

, . , , , . , , . , .

- , . , , . , , , , , , -.

+5

- .

+1

, . .

, .

0

/ . Java - FIFO.

0

All Articles