Align libgc vcxproj with makefile.
[mono.git] / mono / tests / sgen-bridge.cs
1 using System;
2 using System.Collections;
3 using System.Threading;
4
5 public class Bridge {
6         public static int bridges_done;
7         
8         public object[] links = new object [10];
9         ~Bridge () {
10                 ++bridges_done;
11         }
12 }
13
14 class Driver {
15         static int Main () {
16                 int count = Environment.ProcessorCount + 2;
17                 var th = new Thread [count]; 
18                 for (int i = 0; i < count; ++i) {
19                         th [i] = new Thread ( _ =>
20                         {
21                                 var lst = new ArrayList ();
22                                 for (var j = 0; j < 5 * 1000 * 1000; j++) {
23                                         lst.Add (new object ());
24                                         if ((j % 9999) == 0)
25                                                 lst.Add (new Bridge ());
26                                         if ((j % 10000) == 0)
27                                                 new Bridge ();
28                                         if ((j % 500000) == 0)
29                                                 lst = new ArrayList ();
30                                         
31                                 }
32                     });
33                 
34                         th [i].Start ();
35                 }
36
37                 for (int i = 0; i < count; ++i)
38                         th [i].Join ();
39
40                 GC.Collect (2);
41                 
42                 return Bridge.bridges_done > 0 ? 0 : 1;
43         }
44 }