The best way to identify a thread is through its managed id:
Thread.CurrentThread.ManagedThreadId;
Since a finalizer always runs in the GC's thread you can create a finalizer that will save the thread id (or the thread object) in a static valiable.
Sample:
public class ThreadTest {
public static Thread GCThread;
~ThreadTest() {
ThreadTest.GCThread = Thread.CurrentThread;
}
}
in your code just create an instance of this class and do a garbage collection:
public static void Main() {
ThreadTest test = new ThreadTest();
test = null;
GC.Collect();
GC.WaitForPendingFinalizers();
Console.WriteLine(ThreadTest.GCThread.ManagedThreadID);
}