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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T12:35:28+00:00 2026-05-11T12:35:28+00:00

In C#, a class field means every thread has its own instance of that

  • 0

In C#, a class field means every thread has its own instance of that object.

E.g. thread 1 will have its own instance of object a, as will object b.

So 2 users of a web application, on different PCs, should be accessing an instance field (Say a collection) under different, threads, right?

This makes me beg the question, why would I need to write code to synchronise the collection? If the collection is instance based and not shared state.

Is it only in the fact that I may have another thread attempt to read the collection as I modify its state. I say ‘Is it’ because this is only a possible case through code I actually write? E.g. spawn one thread to read a non-synchronised collection, and use the original thread to write to the collection. Or is there any other gotcha?

I have put this in the beginner section as this seems to be a fundamental question.

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. 2026-05-11T12:35:29+00:00Added an answer on May 11, 2026 at 12:35 pm

    In C#, a class by default does NOT have it’s own instance of each object.

    Class instances and threads are two separate constructs (unless a member is flagged [ThreadStatic], or some other exception). If you create instances, and then run a separate thread, it will be working on the same instances (unless the separate thread creates its own instances of objects).

    Since the threads will, normally, work on the same instances (in order to share data and state), you need to synchronize them appropriately.

    If the threads never share state or instances of objects, then you do not need to worry about synchronization. This is rare in practice, though – typically threads are working on some type of shared data. If each spawned thread creates its own objects, and no other threads talk to them, you can ignore synchronization.

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

Sidebar

Ask A Question

Stats

  • Questions 133k
  • Answers 133k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Problem solved. In my usercontrol's Constructor I found a DOUBLE… May 12, 2026 at 6:33 am
  • Editorial Team
    Editorial Team added an answer I'm not sure if this is exactly what you're looking… May 12, 2026 at 6:33 am
  • Editorial Team
    Editorial Team added an answer You might have your repository decoupled because of injection, not… May 12, 2026 at 6:33 am

Related Questions

Recently I've bumped into a realization/implementation of the Singleton design pattern for C++. It
OK - Python newbie here - I assume I am doing something really stupid,
This is a detail question for C#. Suppose I've got a class with an
Does anyone know if it possible to define the equivalent of a java custom

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.