예제 #1
0
        public void TestBug_55909()
        {
            rwlock = new ReaderWriterLock();
            ThreadRunner tr = StartThread(new ThreadStart(Bug_55909_Thread2));

            Thread.Sleep(200);
            rwlock.AcquireReaderLock(Timeout.Infinite);
            try {
                LockCookie lc = rwlock.UpgradeToWriterLock(Timeout.Infinite);
                Thread.Sleep(500);
            }
            finally { rwlock.ReleaseReaderLock(); }

            tr.Join();
        }
예제 #2
0
        public void TestReaderMustWaitWriter()
        {
            // A thread cannot get the reader lock if there are other threads
            // waiting for the writer lock.

            rwlock = new ReaderWriterLock();
            rwlock.AcquireWriterLock(200);

            ThreadRunner tr = StartThread(new ThreadStart(ReaderMustWaitWriter_2));

            Thread.Sleep(200);

            RunThread(new ThreadStart(AcquireLock_readerFails));

            rwlock.ReleaseReaderLock();
            tr.Join();
        }
예제 #3
0
        public void TestBug_55909_bis()
        {
            rwlock = new ReaderWriterLock();
            ThreadRunner tr1 = StartThread(new ThreadStart(Bug_55909_bis_ReaderWriter));

            Thread.Sleep(100);
            ThreadRunner tr2 = StartThread(new ThreadStart(Bug_55909_bis_Reader));

            Thread.Sleep(100);
            ThreadRunner tr3 = StartThread(new ThreadStart(Bug_55909_bis_Writer));

            Thread.Sleep(100);
            ThreadRunner tr4 = StartThread(new ThreadStart(Bug_55909_bis_Reader));

            tr1.Join();
            tr2.Join();
            tr3.Join();
            tr4.Join();
        }
예제 #4
0
        void RunThread(ThreadStart ts)
        {
            ThreadRunner tr = StartThread(ts);

            tr.Join();
        }