Ejemplo n.º 1
0
        public void AcquireReleaseInDifferentThreads()
        {
            Semaphore            s       = new Semaphore(0);
            AcquireReleaseWorker worker1 = new AcquireReleaseWorker(s);
            Thread thread1 = new Thread(new ThreadStart(worker1.DoWork));

            thread1.Start();
            Thread.Sleep(300);
            s.Release();
            s.Release();
            s.Acquire();
            s.Acquire();
            s.Release();
            thread1.Join();
        }
Ejemplo n.º 2
0
 public void AcquireReleaseInDifferentThreads()
 {
     Semaphore s = new Semaphore(0); 
     AcquireReleaseWorker worker1 = new AcquireReleaseWorker(s);
     Thread thread1 = new Thread(new ThreadStart(worker1.DoWork));
     
     thread1.Start();
     Thread.Sleep(300);
     s.Release();
     s.Release();
     s.Acquire();
     s.Acquire();
     s.Release();
     thread1.Join();
     
 }