Microsoft made a big mistake in .NET version 1.0, added the Thread.Suspend () and Resume () methods. These methods were widespread; programmers used them to implement thread synchronization. Why are they completely inappropriate. The problem was that it usually worked. But call Suspend () at the wrong time, and you will close the stream while it is buried inside the Windows call, holding the global lock. And forcing the entire program to a standstill.
This was not the only design mistake they made, the Synchronized method in collection classes also became a disaster. Widely misinterpreted as "returning a thread-safe collection."
Live and learn, all this is fixed in .NET 2.0. One major overhaul was that Thread may not necessarily be an operating system thread that has never been implemented. But it explains why there are two ThreadState enumerations, one for Thread (the .NET version) and the other for ProcessThread (the operating system version). And they closed a loophole for programmers abusing Suspend / Resume, methods were deprecated. And they also closed the backdoor, you cannot find out from ProcessThread that the thread has been suspended.
Function, not error. Do not make the same mistake, knowing that the thread is suspended, this is useless knowledge, it can not be suspended anymore after a microsecond later.
source share