T
tri
Hi,
I have some questions on the meaning of the synchronized keyword.
Scenario 1:
Let's say a thread, ThreadA, calls a synchronized method but the
synchronized method already is locked by another thread, ThreadB.
ThreadA is now blocked and must wait. Does Java put ThreadA to sleep?
Or does ThreadA spin on the cpu?
Also, let's say ThreadC calls the synchronized method. When ThreadB
is done with the lock, does ThreadA have priority? Or is the lock
"randomly" given to either ThreadC or ThreadA?
The above example does not use wait() and notify().
Thank You,
Tri
I have some questions on the meaning of the synchronized keyword.
Scenario 1:
Let's say a thread, ThreadA, calls a synchronized method but the
synchronized method already is locked by another thread, ThreadB.
ThreadA is now blocked and must wait. Does Java put ThreadA to sleep?
Or does ThreadA spin on the cpu?
Also, let's say ThreadC calls the synchronized method. When ThreadB
is done with the lock, does ThreadA have priority? Or is the lock
"randomly" given to either ThreadC or ThreadA?
The above example does not use wait() and notify().
Thank You,
Tri