2 using System
.Collections
;
3 using System
.Threading
;
4 using System
.Collections
.Generic
;
9 static List
<Foo
> list
= new List
<Foo
> ();
15 public static void EnterMonitor (object obj
)
17 for (int i
= 0; i
< 257; i
++)
21 public static void ExitMonitor (object obj
)
23 for (int i
= 0; i
< 257; i
++)
27 public static void CreateFoo (int level
)
30 reference
= new Foo ();
32 /* Allocate a MonoThreadsSync for the object */
33 EnterMonitor (reference
);
34 ExitMonitor (reference
);
37 CreateFoo (level
- 1);
41 public static int Main() {
42 /* Allocate an object down the stack so it doesn't get pinned */
43 typeof (Foo
).GetMethod ("CreateFoo").Invoke (null, new object [] { 100 }
);
45 Console
.WriteLine (".");
49 GC
.WaitForPendingFinalizers ();
51 /* Allocate MonoThreadsSyncs for another thread that are locked */
52 Thread t
= new Thread (new ThreadStart (resurrect
.Func
));
56 /* Make sure that none of the other structures overlap with the original one */
57 Monitor
.Enter (resurrect
);
62 for (int i
= 0; i
< 100; i
++) {
64 /* Make sure these are not collected */