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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T11:21:39+00:00 2026-06-04T11:21:39+00:00

I need to clear some points regarding synchronization at block level. suppose following synchronization

  • 0

I need to clear some points regarding synchronization at block level.

suppose following synchronization blocks are in a same method of a class:

class A{

some_method(){

//BLOCK1
synchronized(OBJ1){
shared code...
}

//BLOCK2
synchronized(OBJ1){
shared code...
}

//BLOCK3
synchronized(OBJ2){
shared code...
}
}

}

Following queries:

1) IS this right that if one thread enters block1 by obtaining lock on OBJ1, then no other thread can enter into Block2 as long as first thread holds lock on OBJ1, but other thread can run block3 simultaneously ?

2)Does first thread need to obtain lock on OBJ1 again if enters block2 after completing block1?

3)if first thread calls some code in block2, from block1 then will it have to release the lock on OBJ1 obtain during first block execution and again obtain it OR same lock obtain during first block will work?

Now suppose block1 is in a method of one class and blockk2 and 3 are in a method of some other class

4)Same as in point 1 holds true as synchronization is happening by obtaining lock on some third class obj (OBJ1,OBJ2)?

  • 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-04T11:21:41+00:00Added an answer on June 4, 2026 at 11:21 am
    1. Yes, it’s correct.
    2. Yes, since the block is synchronized on OBJ1
    3. I don’t understand what you mean. If what you’re asking is “are locks reentrant?”, then yes. A thread which already has a lock on an object can enter another block synchronized on the same object.
    4. Yes. Where the code is doesn’t matter. What matters is if the thread has the lock or not.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to do some clean up work when I am going to terminate
I need to do testing on clean machines frequently so I need some kind
I need to clear all APC cache entries when I deploy a new version
I need to clear the default values from input fields using js, but all
I had a requirement where I need to clear off the select all checkbox
OK, I need to be clear, I am not a genius when it comes
Do I need to release a Core Foundation objects to clear up memory? And
It's not clear to me if the Eclipse plugin completely replaces the need to
From the bin > Debug folder it's clear I will need to copy the
I have to edit my question just to make it clear. What I need

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.