Merge pull request #1168 from esdrubal/iriparsing
[mono.git] / mono / tests / finalizer-wait.cs
1 using System;
2 using System.Threading;
3 using System.Runtime.ConstrainedExecution;
4
5 class P {
6
7         static public int count = 0;
8         ~P () {
9                 // Console.WriteLine ("finalizer done");
10                 count++;
11         }
12 }
13
14 class T {
15         static int Main () {
16                 for (int i = 0; i < 1000; ++i) {
17                         var t = new Thread (() => {
18                                         P p = new P ();
19                                 });
20                         t.Start ();
21                         t.Join ();
22
23                         GC.Collect ();
24                         GC.WaitForPendingFinalizers ();
25                         if (P.count != i + 1)
26                                 return 1;
27                 }
28                 return 0;
29         }
30 }