Beispiel #1
0
        public void Test()
        {
            IntQueue iq = new IntQueue();
            Thread   t  = new Thread(delegate(object o)
            {
                // put child thread code here
                IntQueue miq = (IntQueue)o;
                miq.dequeue();
            });
            Thread t2 = new Thread(delegate(object o)
            {
                IntQueue miq = (IntQueue)o;
                iq.enqueue(2);
            });

            t.Start(iq);
            t2.Start(iq);
            iq.enqueue(1);
            t.Join();
            t2.Join();
            // check consistency of state
            Assert.IsFalse(iq.empty());
        }