[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Dotgnu-pnet-commits] CVS: pnetlib/tests/runtime/System/Threading TestM
From: |
Thong Nguyen <address@hidden> |
Subject: |
[Dotgnu-pnet-commits] CVS: pnetlib/tests/runtime/System/Threading TestMonitor.cs,1.2,1.3 |
Date: |
Tue, 08 Jul 2003 00:59:12 -0400 |
Update of /cvsroot/dotgnu-pnet/pnetlib/tests/runtime/System/Threading
In directory subversions:/tmp/cvs-serv13423
Modified Files:
TestMonitor.cs
Log Message:
Changed order of some tests to make more sense.
Index: TestMonitor.cs
===================================================================
RCS file:
/cvsroot/dotgnu-pnet/pnetlib/tests/runtime/System/Threading/TestMonitor.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** TestMonitor.cs 8 Jul 2003 02:52:55 -0000 1.2
--- TestMonitor.cs 8 Jul 2003 04:59:08 -0000 1.3
***************
*** 114,117 ****
--- 114,167 ----
}
+ bool flag;
+ object monitor = new object();
+
+ private void ExclusionRun1()
+ {
+ lock (monitor)
+ {
+ Thread.Sleep(1000);
+
+ flag = true;
+ }
+ }
+
+ private void ExclusionRun2()
+ {
+ /* Wait for thread1 to obtain lock */
+
+ Thread.Sleep(100);
+
+ lock (monitor)
+ {
+ /* Fails if lock didn't wait for thread1 */
+
+ failed = !flag;
+ }
+ }
+
+ public void TestMonitorExclusion()
+ {
+ if (!TestThread.IsThreadingSupported)
+ {
+ return;
+ }
+
+ Thread thread1, thread2;
+
+ flag = false;
+ failed = true;
+
+ thread1 = new Thread(new ThreadStart(ExclusionRun1));
+ thread2 = new Thread(new ThreadStart(ExclusionRun2));
+
+ thread1.Start();
+ thread2.Start();
+
+ thread1.Join();
+ thread2.Join();
+
+ Assert("Exclusion failed", !failed);
+ }
/*
***************
*** 190,244 ****
AssertEquals("Monitor locking", failed, false);
- }
-
- bool flag;
- object monitor = new object();
-
- private void ExclusionRun1()
- {
- lock (monitor)
- {
- Thread.Sleep(1000);
-
- flag = true;
- }
- }
-
- private void ExclusionRun2()
- {
- /* Wait for thread1 to obtain lock */
-
- Thread.Sleep(100);
-
- lock (monitor)
- {
- /* Fails if lock didn't wait for thread1 */
-
- failed = !flag;
- }
- }
-
- public void TestMonitorExclusion()
- {
- if (!TestThread.IsThreadingSupported)
- {
- return;
- }
-
- Thread thread1, thread2;
-
- flag = false;
- failed = true;
-
- thread1 = new Thread(new ThreadStart(ExclusionRun1));
- thread2 = new Thread(new ThreadStart(ExclusionRun2));
-
- thread1.Start();
- thread2.Start();
-
- thread1.Join();
- thread2.Join();
-
- Assert("Exclusion failed", !failed);
}
}
--- 240,243 ----
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Dotgnu-pnet-commits] CVS: pnetlib/tests/runtime/System/Threading TestMonitor.cs,1.2,1.3,
Thong Nguyen <address@hidden> <=