public static void groupThreadWrite(ConcurrencyUtils.LightSwitch LS) { while (true) { LS.Acquire(); Console.WriteLine("Group thread #" + Thread.CurrentThread.Name); Thread.Sleep(3600); LS.Release(); } }
public static void MutexTestReleaser(ConcurrencyUtils.Mutex mutex) { while (true) { Console.WriteLine("\t\t\t" + Thread.CurrentThread.Name + ": Releasing mutex token"); mutex.Release(); Thread.Sleep(6000); } }
public static void lonelyThreadWrite(ConcurrencyUtils.Semaphore semaphore) { while (true) { semaphore.Acquire(); Console.WriteLine("I'm a lonely thread"); Thread.Sleep(100); semaphore.Release(); } }
public static void SemaphoreTestReleaser(ConcurrencyUtils.Semaphore testSemaphore) { while (true) { Console.WriteLine("\t\t\t" + Thread.CurrentThread.Name + ": Releasing 3 tokens"); testSemaphore.Release(3); // Console.ForegroundColor = ConsoleColor.White; Thread.Sleep(6000); } }