3 using System
.Runtime
.CompilerServices
;
4 using System
.Threading
;
9 public static void Main ()
11 bool finished
= false;
12 AutoResetEvent start_gc
= new AutoResetEvent (false);
13 AutoResetEvent finished_gc
= new AutoResetEvent (false);
15 Thread t1
= new Thread (() => {
16 while (!Volatile
.Read(ref finished
)) {}
19 Thread t2
= new Thread (() => {
20 while (!Volatile
.Read(ref finished
)) {
21 if (start_gc
.WaitOne (0)) {
35 for (int i
= 0; i
< 50 * 40 * 5; ++i
) {
38 finished_gc
.WaitOne ();
41 if ((i
+ 1) % (50) == 0)
43 if ((i
+ 1) % (50 * 40) == 0)
47 Volatile
.Write(ref finished
, true);