When a thread starts, who decides the status of thread; whether it is alive or dead?
A:
You haven't said, but I'm assuming that you're referring to the Thread.IsAlive property in .NET.
This property is set automatically by the framework itself. Basically, when you go Thread.Start()
, the framework runs a bit of code that sets up the thread to be ready to run (including setting IsAlive
to true
), opens a try...catch
block and calls your delegate. When your delegate returns (or an exception is thrown) there is more code inside the framework that executes to tear down the thread (and set IsAlive
to false
).
Dean Harding
2010-10-05 05:55:27