[runtime] Accomplish BITCODE build symbol sharing with only make (#3329)
[mono-project.git] / mono / tests / monitor-abort.cs
blobd1c7a7c477c1c1d53b0fd59376972812e4f22968
1 using System;
2 using System.Threading;
4 public class Program {
5 const int num_threads = 10;
6 static int aborted = 0;
7 static Barrier barrier = new Barrier (num_threads + 1);
9 public static void ThreadFunc (object lock_obj)
11 try {
12 barrier.SignalAndWait ();
13 Monitor.Enter (lock_obj);
14 Monitor.Exit (lock_obj);
15 } catch (ThreadAbortException) {
16 Interlocked.Increment (ref aborted);
17 Thread.ResetAbort ();
21 public static int Main (string[] args)
23 Thread[] tarray = new Thread [num_threads];
25 for (int i = 0; i < num_threads; i++) {
26 object lock_obj = new object ();
27 Monitor.Enter (lock_obj);
28 tarray [i] = new Thread (new ParameterizedThreadStart (ThreadFunc));
29 tarray [i].Start (lock_obj);
32 barrier.SignalAndWait ();
34 for (int i = 0; i < num_threads; i++)
35 tarray [i].Abort ();
37 for (int i = 0; i < num_threads; i++)
38 tarray [i].Join ();
40 Console.WriteLine ("Aborted {0}", aborted);
41 if (aborted != num_threads)
42 return -1;
43 return 0;