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 8138243
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T11:25:51+00:00 2026-06-06T11:25:51+00:00

I have a doubt regarding Java Synchronization . I want to know if I

  • 0

I have a doubt regarding Java Synchronization . I want to know if I have three Synchronized methods in my class and a thread acquires lock in one synchronized method other two will be locked ? I am asking this question because I am confused with the following statement .

While a thread is inside a synchronized method of an object, all other threads that wish to execute this synchronized method or any other synchronized method of the object will have to wait. This restriction does not apply to the thread that already has the lock and is executing a synchronized method of the object. Such a method can invoke other synchronized methods of the object without being blocked. The non-synchronized methods of the object can of course be called at any time by any thread

  • 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-06T11:25:53+00:00Added an answer on June 6, 2026 at 11:25 am

    Synchronization in java is done through aquiering the monitor on some specific Object. Therefore, if you do this:

    class TestClass {
        SomeClass someVariable;
    
        public void myMethod () {
            synchronized (someVariable) {
                ...
            }
        }
    
        public void myOtherMethod() {
            synchronized (someVariable) {
                ...
            }
        }
    }
    

    Then those two blocks will be protected by execution of 2 different threads at any time while someVariable is not modified. Basically, it’s said that those two blocks are synchronized against the variable someVariable.

    When you put synchronized on the method, it basically means the same as synchronized (this), that is, a synchronization on the object this method is executed on.

    That is:

    public synchronized void myMethod() {
        ...
    }
    

    Means the same as:

    public void myMethod() {
        synchronized (this) {
           ...
        }
    }
    

    Therefore, to answer your question – yes, threads won’t be able to simultaneously call those methods in different threads, as they are both holding a reference to the same monitor, the monitor of this object.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have one doubt regarding casting. public void Test(out T a, out T b)
I have basic doubt regarding executable stored in ROM. As I know the executable
I have one doubt regarding audio processing for noise reduction. Is there any free
I have one doubt regarding xml reading using Stax Parser. Expected Result: hq_seq_mast {SEQ_VAL=SEQ_VAL,
I have a doubt regarding downloading data from a web service. One way is
I have a doubt regarding hashset. Why doesn't Hashset take duplicate elements? I know
I have a doubt regarding POJO. Take below example public class User { String
I have a doubt from the book Efective Java. The doubt is regarding equals
I have a basic doubt regarding object creation in java.Suppose i have two classes
I have a doubt regarding HttpServlet class is an abstract class even though there

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.