Skip to content

Instantly share code, notes, and snippets.

@Therzok

Therzok/test.cs Secret

Last active December 6, 2017 14:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Therzok/ce0dc57b27343019a7b3782ed0cbf9b1 to your computer and use it in GitHub Desktop.
Save Therzok/ce0dc57b27343019a7b3782ed0cbf9b1 to your computer and use it in GitHub Desktop.
using System;
using System.Threading;
namespace testccons
{
class MyClass
{
~MyClass()
{
Console.WriteLine("Finalized MyClass");
}
}
class MyClassInThread
{
~MyClassInThread()
{
Console.WriteLine("Finalized MyClassInThread");
}
}
class MainClass
{
public static void Main(string[] args)
{
for (int i = 0; i < 50; ++i) {
SpawnThread();
GC.Collect();
GC.Collect();
GC.Collect();
GC.Collect();
GC.WaitForPendingFinalizers();
}
Console.WriteLine("Program termination");
}
static void SpawnThread()
{
var th = new Thread(MyThreadStart)
{
IsBackground = true,
};
new MyClass();
th.Start(new MyClassInThread());
th.Join();
}
static void MyThreadStart(object param)
{
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment