In .NET net, there is no such thing as "global variable". It does not change anything. The important aspect is not "global", but the fact you share any objects between threads.
As I already explained, sharing of objects should be minimized. You should try to do the most calculations on stack, as, of course, each thread means using a separate stack.
The best synchronization is no synchronization.
Now, with shared objects, this is the simple pattern which works without race conditions and deadlocks: all access to shared object is guarded by the lock, same shared object with the same lock, locks should be strictly nested (one simplest violation of nesting is at the same time one of the simplest "textbook" example of a deadlock). It is important to release the lock and preserve strict nesting in the case of any exception thrown inside the mutual exclusion area.
Please see again, all links a in my recent answer:
Is this enough to insure mutual exclusion?[
^].
You need to take it all in more serious, regular and fundamental way then you are trying to do with your questions. You need to learn the whole topic on good level and educate yourself on a regular basis.
—SA