Page 1 of 1
About Question enthuware.ocpjp.v7.2.1505 :
Posted: Tue Oct 08, 2013 2:24 pm
by Wisevolk
Hi,
The sleep method doesn't release the lock ? So can we consider the thread not be running ?
Re: About Question enthuware.ocpjp.v7.2.1505 :
Posted: Tue Oct 08, 2013 2:41 pm
by admin
Yes, even if the lock is not released, the thread is not running.
Re: About Question enthuware.ocpjp.v7.2.1505 :
Posted: Tue Dec 08, 2015 12:09 pm
by fariz.siracli
- The thread is trying to enter a synchronized block and the monitor is not free.
In this situation, the thread will be blocked until some other thread calls notify()/notifyAll() on the object whose synchronized block this thread is trying to enter.
In this case why thread trying to get monitor, will be blocked until other thread call notify()/notifyAll()? It may be the case that thread tries to get monitor for just synchronized method or block and there is no called wait method.
Isn't it possible ?
And also when some thread tries to get monitor isn't it in running state still?
Re: About Question enthuware.ocpjp.v7.2.1505 :
Posted: Tue Dec 08, 2015 8:18 pm
by admin
When the thread tries to get a monitor and if the monitor is not free, then it gets blocked. It was running but not anymore. That is how threading has been designed in Java. Only when another thread that is holding the lock notifies blocked threads, will the blocked threads will be unblocked and become ready to run again.
Re: About Question enthuware.ocpjp.v7.2.1505 :
Posted: Wed Jan 04, 2017 12:45 pm
by jagoneye
Also please note that JLS considers a running and runnable thread as 'runnable' state only.
Re: About Question enthuware.ocpjp.v7.2.1505 :
Posted: Wed Nov 10, 2021 1:20 pm
by Javatje
In which of the following cases a thread will definitely be alive but not be running?
The thread has issued a call to wait( ). (Assuming that the thread owns the lock for the object on which wait is called.)
In this situation, the thread will be blocked until some other thread calls notify()/notifyAll() on the object on which this thread has called wait() and this thread is able to reacquire the lock for this object.
Since the thread has already issued the call. Therefore, another thread may have called notify(), so the thread is not definitely not running.
Re: About Question enthuware.ocpjp.v7.2.1505 :
Posted: Wed Nov 10, 2021 9:20 pm
by admin
Zoom in a little

Right after the call to main, before anything else happens, the thread is definitely not running.
Re: About Question enthuware.ocpjp.v7.2.1505 :
Posted: Fri Nov 12, 2021 5:28 am
by Javatje
"before anything else happens"
This is not stated in the question