Thread.Sleep(5000);
stopwatch.Stop();
Console.WriteLine(stopwatch.ElapsedMilliseconds);
Thread.suspend(5000);
Console.WriteLine(stopwatch.ElapsedMilliseconds);
最佳答案
Sleep在单个线程上使用,它会暂停一个线程一段时间。 Whereas suspend is deprecated .
另请参阅 MSDN 中有关挂起的注释:
Do not use the Suspend and Resume methods to synchronize the activities of threads. You have no way of knowing what code a thread is executing when you suspend it. If you suspend a thread while it holds locks during a security permission evaluation, other threads in the AppDomain might be blocked. If you suspend a thread while it is executing a class constructor, other threads in the AppDomain that attempt to use that class are blocked. Deadlocks can occur very easily.
关于c# - c#中Thread中suspend和sleep的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33412962/