Thread lifecycle in .NET framework Thread lifecycle in .NET framework multithreading multithreading

Thread lifecycle in .NET framework


A thread is blocked if its execution has been suspended by one of the synchronization primitives, such as a lock or a mutex. Any thread that is performing useful work at a given moment is, by definition, not blocked at that moment.

The AbortRequested/Stopped cycle gives the thread an opportunity to perform an orderly shutdown, releasing acquired resources and performing other cleanup tasks.

http://www.albahari.com/threading/


Answers to your questions:

  1. I don't believe this mapping would be as useful as you appear to hope. I've never run across one and never needed it.
  2. There isn't a real need for a "Blocked" state unless you're trying to write something like a deadlock detector (rather advanced). From a typical developer perspective, the OS "blocked" state is transient and can be ignored. (It appears that your code is running, but the OS has nothing to do until the async response is received.)
  3. Imagine the Aborted state as .NET providing an exception handler around all the code in the thread. When an exception is caught, causing the thread to die, .NET translates that to an Aborted state for you. Otherwise, you may not be able to tell the difference between abnormal and normal thread termination.