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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:40:36+00:00 2026-05-26T22:40:36+00:00

EDIT: As it turns out when I was browsing I found a question the

  • 0

EDIT: As it turns out when I was browsing I found a question the appears to be the same as mine which I didn’t find earlier: Difference between lock(locker) and lock(variable_which_I_am_using)

I am looking at some code and trying to get my head around the locking thing and I am getting there I think.

Now I noticed in some code I am reviewing that an object is created like so:

private HashSet<Graphic> clustersInUse = new HashSet<Graphic>();

Then further in the code is used like so:

lock (clustersInUse)
{
   // Do something with the Hashset
}

Now, is there a problem doing this rather than creating a specific object for the lock. Like this:

private object clusterLocker = new object();

What happens if the clustersInUse above somehow gets put into a public property, what happens then?

Also, if something tries to access the clustersInUse without locking it whilst it is locked in another thread what would happen then?

  • 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-05-26T22:40:37+00:00Added an answer on May 26, 2026 at 10:40 pm

    You’ve pretty much answered your own question. For locking, it’s generally better to create an object specifically for the purpose, and usually held privately for use by accessor methods that express synchronisation logic at a high level.

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

Sidebar

Related Questions

Solution Edit: Turns out you can't use the PHP SDK to return the correct
Edit: It turns out I missed something obvious, but I'm going to leave the
EDIT: solved it, turns out I should use %c not %s because foodSelect and
Sometimes, VS wont let me do edit and continue, and it turns out it's
EDIT: it turns out it's NOT a problem.. pfew! phpMOadmin is not able to
EDIT: It turns out I am not very intelligent. I should have checked first
I'm trying to figure out the difference between Groovy: def name = stephanie Java:
Is there any difference between using the field ID or _ID from a MongoDB
IE8 is out and apparently it automatically turns on script (JavaScript) debugging whenever you
EDIT: Duplicate of Should Entity Framework Context be Put into Using Statement? I've been

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.