Re: static classes & threading
- From: "Bruce Wood" <brucewood@xxxxxxxxxx>
- Date: 19 Apr 2005 12:20:25 -0700
I think that your confusion (and ours) arises because you haven't
stated where you are storing your data. Threading problems don't crop
up based on whether you have static or instance methods. They crop up
based on whether the threads share data, or state.
If DoSomeTask creates a connection _and then stores that connection in
a static variable_ that is visible to other threads, then you'll have
contention problems and will have to introduce a lock. If, however,
DoSomeTask creates a connection and puts the reference to it in a local
variable (which would be on the stack), there is no interaction between
threads, because each thread has its own stack.
If your static class has static state as well, then you have to worry
about locks. If it has no state, there should be no threading problems
and no waiting.
.
- Follow-Ups:
- Re: static classes & threading
- From: Frank Rizzo
- Re: static classes & threading
- References:
- static classes & threading
- From: Frank Rizzo
- Re: static classes & threading
- From: Gabriel Lozano-Morán
- Re: static classes & threading
- From: Frank Rizzo
- static classes & threading
- Prev by Date: Re: Problems with File manipulation
- Next by Date: Re: comment a structure
- Previous by thread: Re: static classes & threading
- Next by thread: Re: static classes & threading
- Index(es):
Loading