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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T02:48:44+00:00 2026-06-12T02:48:44+00:00

if I have two locks nested say (I am concerning java here) synchronized (clientInfMutex)

  • 0

if I have two locks nested
say (I am concerning java here)

synchronized (clientInfMutex) {
...
    synchronized (clientInfMutex) {
        //Will this part executable?


  }


}

Will the inner part executable? the concern is that when the outer lock is getting the lock, the inner lock might not be able to lock the lock again. If the inner part is not executable, is there a mechanism, such that if I hold the lock in the outer lock already, I will be able to access the inner lock without a problem? Thanks.

  • 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-12T02:48:46+00:00Added an answer on June 12, 2026 at 2:48 am

    Yes.
    Because the thread will already have the lock.
    In Java native locks are reentrant

    Everytime the JVM hits a synchronized block, it checks if it has that lock, if no, then it waits for that lock, or else it increments an internal counter for that lock, and executes the enclosed block

    Note that this is assuming that clientInfMutex points to same object in both statements. If, for e.g., you did a clientInfMutex = new Object() between the two synchronized blocks, then your thread will wait for the lock of the new object.

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

Sidebar

Related Questions

I have two nested DropDownLists (the value selected in the 1st ddl will limit
I have funcion, which is called very frequently. This function has two nested for
What I'm talking about here are nested classes. Essentially, I have two classes that
I have two tables which looks something like this Table Queue int ID; string
I have two singletons, the first one's header looks like this (I've omitted everything
I have two tables Department and Employee . Department table looks like this: ID
here is what my code looks like i have two forms: class Form_1 extends
So we have a java class with two ArrayLists of generics. It looks like
Have two folders with approx. 150 java property files. In a shell script, how
Is it possible for a model to belong_to, two models and have a nested

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.