[netcore] Ongoing work. (#13391)
[mono-project.git] / mono / tests / sgen-bridge.cs
bloba45d4f8b7fde087b975e1002127dbbd535d9dd2c
1 using System;
2 using System.Collections;
3 using System.Threading;
5 public class Bridge {
6 public static int bridges_done;
8 public object[] links = new object [10];
9 ~Bridge () {
10 ++bridges_done;
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 ( _ =>
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 ();
32 });
34 th [i].Start ();
37 for (int i = 0; i < count; ++i)
38 th [i].Join ();
40 GC.Collect (2);
42 return Bridge.bridges_done > 0 ? 0 : 1;