Re: static classes & threading



That's the whole point of multithreading :) So unless there is a
mutual-exclusion lock in your method the second thread will not wait for the
first thread to finish executing the static method.

Gabriel Lozano-Morán
Software Engineer
Sogeti

"Frank Rizzo" <none@xxxxxxxx> wrote in message
news:eWMX0gQRFHA.2252@xxxxxxxxxxxxxxxxxxxxxxx
> Hello,
>
> I have a class with all static methods that is called by multiple threads.
> I was wondering what effect that has on the competing threads.
> Does Thread2 have to wait until Thread1 is done with the
> StaticClass.Method1 before it can use it?
>
> What if I removed static methods and made all the threads instantiate its
> own copy of the class? Would that remove the waiting contention?
>
> Thanks.


.



Relevant Pages

  • Re: static constructor multithreaded?
    ... Does the second thread block until the first ... Static constructors are only ever called once, and static methods are ... implicitly threadsafe, so you shouldn't have to take any special ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: More Threaded Cache Loading questions...
    ... >Static methods ARE singletons... ... >> which calls some static business methods to fetch data ... Could it be that my static methods are acting ... >> waits for the first thread to complete. ...
    (microsoft.public.dotnet.framework.aspnet)