示例#1
0
        public static void Main()
        {
            ReentrantLock _lock = new ReentrantLock();
            Condition     cond  = _lock.NewCondition();

            Thread c = new Thread(() =>
            {
                _lock.Lock();
                cond.Wait();
                Console.WriteLine("AQUI ");
                _lock.Unlock();
            });

            Thread l = new Thread(() =>
            {
                Thread.Sleep(1000);
                _lock.Lock();
                cond.Pulse();
                _lock.Unlock();
            });

            c.Start();
            l.Start();
            Thread.Sleep(5000);
            Console.WriteLine("Pilihla");
        }
示例#2
0
 public Condition(ReentrantLock master)
 {
     _cond   = new Object();
     _master = master;
 }
示例#3
0
 public SemaforoFifo(int units)
 {
     _units   = units;
     _requeue = new LinkedList <Request>();
     _lock    = new ReentrantLock();
 }