R
Ravi
Hi,
Just wanted to clarify. Please correct me if I went wrong anywhere.
Threads seize their current execution in two ways
1) When they encounter a synchronized block and the object lock is not
available. They would be put in a Object Lock Monitor Queue. This
queue is managed by JVM. That is object lock acquiring and releasing
is automatically taken care by JVM on behalf of the thread
(programmer).
2) When the thread calls wait() from a synchronized block. It is then
put in Object's wait queue for which it acquired the lock and the lock
is released. Notify() by another thread brings it backs to life and
the fight for Object lock begins when it becomes the current execution
thread. The wait() and notify() have to programmed explicitly.
Thanks,
Ravi.
Just wanted to clarify. Please correct me if I went wrong anywhere.
Threads seize their current execution in two ways
1) When they encounter a synchronized block and the object lock is not
available. They would be put in a Object Lock Monitor Queue. This
queue is managed by JVM. That is object lock acquiring and releasing
is automatically taken care by JVM on behalf of the thread
(programmer).
2) When the thread calls wait() from a synchronized block. It is then
put in Object's wait queue for which it acquired the lock and the lock
is released. Notify() by another thread brings it backs to life and
the fight for Object lock begins when it becomes the current execution
thread. The wait() and notify() have to programmed explicitly.
Thanks,
Ravi.