It depends on how you use it.
UPDATE: This next paragraph is wrong. It is a static class. I'll leave it here for posperity
Here, you don't have a static class, you have a static instance of a class. The difference is that you still need to initialize it. The best way is to use "
Lazy Initialization[
^]". This is a shorthand way of thread-safe initialization.
If the class is a "stuct" then you don't have to worry too much about access to the parameters, but in either case it's better to be safe than sorry.
A "Lock" encapsulation prevents more than one thread entering the code at any one time.
The Lock is written like so:
UPDATE: Locks are used to avoid threads getting in each others way. The below example is an example only of how locks work.
var lockObj= new object();
public static int _prop;
public static int prop{
get{
Lock(lockObj){
return _prop;
}
}
set{
Lock(lockObj){
_prop = value;
}
}
}
The getter and setter both have locks with the same key. If a thread enters either one then any other thread will have to wait for the first thread to exit the lock before it can enter.
That's the basics of manual thread-safety. There are other things to keep in mind such as Thread Join, Wait etc. A google search should highlight the nuances.
Hope that helps ^_^
Andy