Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7129975
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T11:18:02+00:00 2026-05-28T11:18:02+00:00

I just have a question in regards to threads that run concurrently and the

  • 0

I just have a question in regards to threads that run concurrently and the lock they have on an object. From what I understand is that the thread that calls the wait() method will go on a waiting list and allows another thread from a blocked list to take over the lock on and object(within synchronized code).
If this thread that now has the lock on the object calls the notify() method it wakes up the thread that called wait() and it is moved to the blocked list.

What happens to the thread that calls the notify() method. Does it still have a lock on the object or does it now go on a waiting list?

regards

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T11:18:02+00:00Added an answer on May 28, 2026 at 11:18 am

    Only one thread can hold the lock for an object. The wait() and notify() methods must be called while the thread holds the lock on the object you call these methods on; if they don’t (for example, because you didn’t synchronize on the object), you’ll get an IllegalMonitorStateException.

    When you call wait(), then the thread gives up the lock and goes on a waiting list (stops executing). When wait() returns, the thread will have obtained the lock again. However, the thread that calls notify() is still holding the lock, so the waiting thread will not resume before the notifying thread exits the synchronized block or method so that it releases the lock on the object.

    By calling notify() the thread is not giving up the lock on the object.

    A possible sequence of events would be:

    • Thread 1 goes into a synchronized block, obtaining the lock for the object
    • Thread 1 calls wait() on the object, giving up the lock, stops executing
    • Thread 2 goes into a synchronized block, obtaining the lock for the object
    • Thread 2 calls notify() on the object, but still holds the lock
    • Thread 1 is awakened and tries to obtain the lock, but it can’t because Thread 2 still has it (so Thread 1 has to wait for the lock)
    • Thread 2 exits the synchronized block and releases the lock
    • Thread 1 can now obtain the lock and returns from wait()
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just asked this question an hour ago but with regards to IE8
I just have a question regarding SimpleJSON's documentation. Is it implicit understood that functions
I have a question that I just don't feel like I've found a satisfactory
I just have a little question with regards to connecting C to MySQL. Well,
I have a question that might seem basic but I just cannot figure out
I just have a small question that I would like some clarification about, if
I just have a question thats been pozzling my head all morning. I want
I just have a quick question about how to get the length of a
I have just a question... I'm seeing this coding style in various php scripts
I have this question, i am just throwing it out there. I am implementing

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.