[netcore] Implement/fix enum/nullable comparers.
[mono-project.git] / mono / tests / sgen-weakref-stress.cs
blob9a43b7200d652ffc20bd96eb3756b4a9e40f9b3f
1 using System;
2 using System.Threading;
4 public class Tests
6 const int thread_count = 10;
7 const int weakrefs_per_thread = 5000;
8 const int crash_loops = 5;
9 public static void CrashRound () {
10 var t = new Thread [thread_count];
11 int fcount = 0;
12 for (int i = 0; i < thread_count; ++i) {
13 t [i] = new Thread (delegate () {
14 for (int j = 0; j < weakrefs_per_thread; ++j) {
15 new WeakReference (new object ());
17 Interlocked.Increment (ref fcount);
18 });
21 for (int i = 0; i < thread_count; ++i)
22 t [i].Start ();
24 while (true) {
25 if (fcount == thread_count)
26 break;
27 GC.Collect ();
28 Thread.Sleep (1);
32 public static void Main () {
33 for (int i = 0; i < crash_loops; ++i) {
34 Console.WriteLine ("{0}", i);
35 CrashRound ();