• Post Reply Bookmark Topic Watch Topic
  • New Topic

Wait inside Synchronize doubt

 
Abhijit Choudhury
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well can any other thread call a synchronized method
when some other thread has already called wait intside that method

Remember its a sync method and a thread is already inside and due to some condition has called wait.

Can some other thread call that sync method at this point of time.

Or do i need to wake that thread using notify and then when it completes some other thread can access that sync method.

Anyways Merry Christmas
 
Nitesh Kant
Bartender
Posts: 1638
IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Calling wait on an object relinquishes any lock(s) that the thread already had on that object, so, any other thread can enter that synchronized block/method.
FYI, Thread.sleep() does not relinquishes the locks.
 
Abhijit Choudhury
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thnx Nitesh got it
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!