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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T19:39:04+00:00 2026-05-12T19:39:04+00:00

Quick version of my question: Is the only time you need to use lock

  • 0

Quick version of my question:

Is the only time you need to use “lock” when you are accessing the same instance of an object? For example, if i am instantiating everything new within my thread entry method, do I have to worry about locking any objects?

Detailed Explanation of my question:

My scenario is, I have a work object with a unique identifier, and that work object has 1 method in it. Inside that method, I create new instances of multiple web service proxies and store the information retrieved from those calls in public properties of the work object. Once all work has been done (all threads have finished), I store the information to a database.

Any reason to consider using “lock”?

  • 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-12T19:39:04+00:00Added an answer on May 12, 2026 at 7:39 pm

    You only need to use lock on one or more sections of code that should not be run simultaneously. For example, if you have code that uses the same List<T> on multiple threads, you would need to use a lock.

    In your case, if you have a separate work object per thread, and if they don’t interact with any other work objects or access any shared state, you should be fine.

    For a more specific answer, please post more details, or, preferably, source.


    EDIT: In response to your comment, it depends on the implementation of InvokeService. As long as it doesn’t access any other static members, you’ll probably run fine without any locks.

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

Sidebar

Related Questions

Quick Question Is it possible to have more than 1 config file in a
Quick version: We're looking for a way to force a transaction to rollback when
I have reviewed DashCommerce, nopCommerce and DotShoppingCart for possible use and all of them
We are currently using VSS for version control. Quite few of our developers are
I am experiencing a weirdest thing for the last couple of days. I found
So we have this web app where we support UTF8 data. Hooray UTF8. And
I am developing a little data warehouse system with a web interface where people
I just started using eclipse for some personal projects and am finding the transition
Say I have some special class, WrappedDataTable , and I want to associate each

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.