Thread go = new Thread();
try {
go.Start()
// Do Work
}// Do Work
catch { }
finally { go = null; }
As per my understanding, setting the thread to null doesn't specifically "kill" that thread; the GC may be able to free up the space used by that thread object, but what about the actual memory space, stack, etc. that has been assigned to the thread by the Windows OS Because I thought that you can't technically kill a Windows thread without raising the ThreadAbortException Can someone help answer these questions
Thanks in advance.

CLR Thread Object
diver182
Hi,
The thread will die by natural causes in your example, remember that you must keep it alive feeding it with instructions. When you mean "kill" a thread actually is aborting a thread that still has instructions to run.
In your example, the "go" object is a reference type as you well know and because is in your method the "go" reference will be destroyed when the method ends, therefore adding "go = null;" is a "waste of energy" as the stack jump will do the job for you. The main object will still live on the heap until the GC collects and put it on the finalization queue. Once the finalization is run the object is actually killed.
Regarding your question about killing it, based in what I have explained you if you have a thread that has plenty of instructions to run and you assign null to the "reference" the thread will continue running until it finishes or the GC terminates it.
You can try it:
{
Thread YourLongThread = new Thread(new ThreadStart(Test));
YourLongThread.Start();
YourLongThread.IsBackground = false;
YourLongThread = null;
}
private void Test(object state)
{
Thread.Sleep(20000);
}
You will see that the thread continues running after the null assigment.
Hope this helps you.
NoEgo
mbp
It's not wise to "kill" a thread, if could be modifying a complex invariant (e.g. writing data to a file) that could get corrupted if you externally terminate a thread. The best way is to write a thread routine that polls a synchronization object that another thread can "set" to signal the thread to exit on its own. See 'System.Threading.Thread.Suspend()' is obsolete: 'Thread.Suspend has been deprecated... for an example of writing a thread routine that allows for cooperative terminate (and suspension).