new Mutex : Mutex : Thread C# Source Code


Custom Search

C# Source Code » Thread » Mutex »

 

new Mutex








    
 


using System;
using System.Threading;


class NETMutex {
    static Mutex myMutex;

    public static void Main() {
        myMutex = new Mutex(true, "AAA");
        NETMutex nm = new NETMutex();
        Thread t = new Thread(new ThreadStart(nm.Run));
        t.Start();
        Thread.Sleep(5000);
        myMutex.ReleaseMutex();
        myMutex.WaitOne();
    }

    public void Run() {
        Console.WriteLine("In Run");
        myMutex.WaitOne();
        Console.WriteLine("Thread sleeping for 10 secs");
        Thread.Sleep(10000);
        Console.WriteLine("End of Run() method");
    }
}

 
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Thread
» Mutex