class ThreadSafe { public static readonly object _locker = new object(); public static int _val1; public int _val2 = 1; public void Go() { lock (_locker) { if (_val2 != 0) Console.WriteLine (_val1 / _val2); _val2 = 0; } } }
lock
_val1
_val2
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)