All pastes #885430 Raw Edit

Untitled

public text v1 · immutable
#885430 ·published 2008-01-30 22:23 UTC
rendered paste body
class ThreadSafe {
  static bool done;
  static object locker = new object();
 
  static void Main() {
    new Thread (Go).Start();
    Go();
  }
 
  static void Go() {
    lock (locker) {
      if (!done) { Console.WriteLine ("Done"); done = true; }
    }
  }
}