예제 #1
0
 public static void groupThreadWrite(ConcurrencyUtils.LightSwitch LS)
 {
     while (true)
     {
         LS.Acquire();
         Console.WriteLine("Group thread #" + Thread.CurrentThread.Name);
         Thread.Sleep(3600);
         LS.Release();
     }
 }
예제 #2
0
 public static void lonelyThreadWrite(ConcurrencyUtils.Semaphore semaphore)
 {
     while (true)
     {
         semaphore.Acquire();
         Console.WriteLine("I'm a lonely thread");
         Thread.Sleep(100);
         semaphore.Release();
     }
 }
예제 #3
0
 public static void latchAcquire(ConcurrencyUtils.Latch latch)
 {
     Console.WriteLine(Thread.CurrentThread.Name + "trying to acquire");
     latch.Acquire();
     Console.WriteLine(Thread.CurrentThread.Name + "got through the latch");
 }
예제 #4
0
 public static void SemaphoreTest(ConcurrencyUtils.Semaphore testSemaphore)
 {
     while (true)
     {
         // Console.ForegroundColor = ConsoleColor.Red;
         Console.WriteLine(Thread.CurrentThread.Name + ": Trying to Acquire...");
         testSemaphore.Acquire();
         // Console.ForegroundColor = ConsoleColor.Green;
         Console.WriteLine(Thread.CurrentThread.Name + ": acquired token!");
         Thread.Sleep(DELAY_SECONDS * 1000);
     }
 }