Fix lookup for all SourceLink mappings, prefer local file over SourceLink
[mono-project.git] / mono / tests / bug-59281.cs
blob94250c277a711f6ff39c20bdb540b4c490cf06a8
1 using System;
2 using System.Threading;
4 class Driver
7 static readonly Mutex[] mutexes = new Mutex[2];
9 public static void Main(string[] args)
11 for (int i = 0; i < mutexes.Length; i++) {
12 mutexes [i] = new Mutex();
15 Thread thread1 = new Thread(() => {
16 for (int i = 0; i < 1; i++) {
17 int idx = -1;
18 try {
19 idx = WaitHandle.WaitAny (mutexes);
20 Console.WriteLine($"Thread 1 iter: {i} with mutex: {idx}");
21 } finally {
22 if (idx != -1)
23 mutexes [idx].ReleaseMutex();
27 Console.WriteLine("Thread 1 ended");
28 });
30 thread1.Start();
31 thread1.Join();
33 Thread thread2 = new Thread(() => {
34 for (int i = 0; i < 1000; i++) {
35 int idx = -1;
36 try {
37 idx = WaitHandle.WaitAny (mutexes);
38 Console.WriteLine($"Thread 2 iter: {i} with mutex: {idx}");
39 } finally {
40 if (idx != -1)
41 mutexes [idx].ReleaseMutex();
45 Console.WriteLine("Thread 2 ended");
46 });
48 thread2.Start();
49 thread2.Join();