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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T15:29:26+00:00 2026-06-11T15:29:26+00:00

It is well known that synchronization is recommended on a final private object (vs.

  • 0

It is well known that synchronization is recommended on a final private object (vs. synchronizing on this or even a protected data member).

But what happens when I have multiple classes (modules) in my application that need to synchronize on a common object?

Is there a way to reconcile these two seemingly contradicting requirements?

To better explain, if I have a private data member of class Owner defined as:

private final Object $01pfo = new Object[0]; 

Then any method in Owner could simply use it:

  protected void anyMethod()  {
    synchronized ($01pfo) {
          // do your thing
    }
  }

But if I want to synchronize on $01pfo from a different class (say User), is my only option to make $01pfo protected or public?

protected final Object $01pfo = new Object[0]; 

Is there a better approach? or solution?

  • 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-11T15:29:28+00:00Added an answer on June 11, 2026 at 3:29 pm

    synchronized blocks are working well in case if they are not spread among several objects.

    in case if you need to synchronize operations using single lock in several classes – it’s better to take a look at Lock implementations.

    It will give you much more freedom in granularing access to resources in several threads

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

Sidebar

Related Questions

I need a list of any well known Linux applications that uses object detection
There is this well-known problem that browsers don't put Ajax request in the request
Its well known that we can store DATA in dynamically allocated memory. However, I
It is a well known problem that IE caches too much of html, even
It's well-known that the worst-case runtime for heapsort is Ω(n lg n), but I'm
It is well known that the user can define stream manipulators like this: ostream&
It is well known that regular expressions are powerful. But it is also known
i have this pretty well known script that i am trying to get working,
It is well-known that monoids are stunningly ubiquitous in programing. They are so ubiquitous
Its a well known fact that a static method can work only on static

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.