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

  • Home
  • SEARCH
  • 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 8715521
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:51:57+00:00 2026-06-13T05:51:57+00:00

What if a synchronized method calls another synchronized method (in another class), which does

  • 0

What if a synchronized method calls another synchronized method (in another class), which does wait(). Will the lock be released in the first synchronized method as well, although being in another class?

E.g.

    public class A {
        private B b;

        public A(B b) {
           this.b = b;
        }

        public synchronized String a() {
           return b.b();
        }
   }

    public class B {

        public synchronized String b() {
            while (!someCondition) wait();
            return "Success!";
        }
    }

So my question is, will it be possible to enter another synchronized method in A during the time someCondition = false? Or does wait() just make it possible to enter other synchronized methods in B while an attempt to enter another synchronized method in A will fail until a() returns?

  • 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-06-13T05:51:59+00:00Added an answer on June 13, 2026 at 5:51 am

    No. While invoking a and subsequently b, no other method can enter neither a or b (or any other synchronized method of classes A or B). b.wait() however releases the lock on all synchronized methods on B since

    public synchronized String b() 
    

    is essentially equivalent to

    public String b() {
       synchronized(this) {
        ..
       }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I write a python class which makes asynchronous method calls using D-Bus. When my
I have an AsyncTask which calls my LocationHandler class method getLocation() which runs a
Hi I have a class with multiple methods in which I require synchronized blocks
When Proguard optimize my application, it seams that all calls to Object#wait() are being
I have main thread which calls another thread. timeout period of second one is
If there is a synchronized method in a class and 1 thread enters it,
If I use synchronize(this) in two methods and one calls the other, will I
What is the difference between a synchronized method and synchronized block in Java ?
What are the disadvantages of making a large Java non-static method synchronized? Large method
I saw a Java example that had a main method labeled as synchronized, calling

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.