In Java if a thread, t2
, attempts to attain a lock, from synchronized, which is currently in use by another thread, t1
, then t2
will switch from runnable to blocked. Correct? What about with ReentrantLock
s?
If the thread t1
finishes using the lock, does t2
then automatically switch back to runnable or do you need to use notifyAll()
? What about with ReentrantLock
usage without a condition. If you aren't using a condition how do you inform the thread t2
that it should switch back to runnable? Is it ever wise, or even possible to use reentrant locks without a condition?
If this question has already been answered (I couldn't find it), I would be grateful if you would link it to me.