"Simon Harvey" <si**********@the-web-works.co.uk> wrote in
news:OY**************@tk2msftngp13.phx.gbl:
Hi all,
I'm considering using a the micorsoft data access block as the main
DAC for my application. A colleage of mine suggested that I might have
a problem with concurrency though
When a method is static, do I need to worry about concurrency?
Any method that does not handle any data external to the method is by
default thread safe, or at least as thread-safe as the parameters to it
are.
As such, a static method that only operates on the parameters it's given,
and those parameters are also thread-safe in the sense that no other
thread is operating on them at the same time, then that method will be
thread safe. Additionally, any local variables held in the class must
also be thread safe in the sense that they must not be depending on other
instances of objects than themselves. For instance, if you create a new
object inside the method, that's ok. If that object adds itself to a
static/shared list somewhere, that code must be thread-safe or you will
have a problem.
If the method (static or not) operates on anything outside of this, like
member variables (static or not), external system resources (files,
serial ports, etc.), then that method must be written specifically with
thread safety in mind.
--
Lasse Vågsæther Karlsen
la***@vkarlsen.no
PGP KeyID: 0x0270466B