Wait() question

R

Razvan

Hi !





I have a question about the behavior of wait. Let's suppose that
thread "A" is in a waiting state with timeout. After the timeout
period, the thread is awaken but the object on which is synchronized
is STILL locked by another thread. What now ? What will be the state
of this thread ? Will it go back to waiting state ? If so, will the
waiting state still have a timeout ? If not, in which state will it go
?




Regards,
Razvan
 
S

Stefan Schulz

Razvan said:
I have a question about the behavior of wait. Let's suppose that
thread "A" is in a waiting state with timeout. After the timeout
period, the thread is awaken but the object on which is synchronized
is STILL locked by another thread. What now ? What will be the state
of this thread ? Will it go back to waiting state ? If so, will the
waiting state still have a timeout ? If not, in which state will it go
?

It will wait (not wait()) to get the lock on the Object it is
synchronized on. Only when all the synchronization locks are satisfied
once more, the next instruction will be run. This is pretty much the
same behaviour you get if two threads attempt to enter a synchronized
block in the first place.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,158
Latest member
Vinay_Kumar Nevatia
Top