-
-
Save Therzok/ce0dc57b27343019a7b3782ed0cbf9b1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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