相关疑难解决方法(0)

为什么来自线程教程的MSDN示例崩溃?

来自MSDN "线程教程"的示例4示例下面的
代码错误在注释"--- errors is here ---".
怎么了?

using System;
using System.Threading;

public class MutexSample
{
    static Mutex gM1;
    static Mutex gM2;
    const int ITERS = 100;
    static AutoResetEvent Event1 = new AutoResetEvent(false);
    static AutoResetEvent Event2 = new AutoResetEvent(false);
    static AutoResetEvent Event3 = new AutoResetEvent(false);
    static AutoResetEvent Event4 = new AutoResetEvent(false);

    public static void Main(String[] args)
    {
        Console.WriteLine("Mutex Sample ...");
        // Create Mutex initialOwned, with name of "MyMutex".
        gM1 = new Mutex(true, "MyMutex");
        // Create Mutex initialOwned, with no …
Run Code Online (Sandbox Code Playgroud)

c# multithreading synchronization mutex thread-safety

5
推荐指数
1
解决办法
843
查看次数