Using lock statement with ThreadPool in C#
问题 I have a multi-threaded program (C#) where I have to share global static variables between threads that may take some time to execute (sending data request to another system using WCF). The problem is that using the lock statement does not seem to guarantee mutual exclusion when it's declared outside of the ThreadPool. static void Main(string[] args) { public static int globalVar = 0; public object locker; System.Timers.Timer timer1 = new System.Timers.Timer(1000); timer1.Elapsed += new