Why is this an issue?
Thread.Suspend
and Thread.Resume
can give unpredictable results, and both methods have been deprecated. Indeed, if
Thread.Suspend
is not used very carefully, a thread can be suspended while holding a lock, thus leading to a deadlock. Other safer
synchronization mechanisms should be used, such as Monitor
, Mutex
, and Semaphore
.
Noncompliant code example
static void Main(string[] args)
{
// ...
Thread.CurrentThread.Suspend(); // Noncompliant
Thread.CurrentThread.Resume(); // Noncompliant
}
Resources