Using synchronized methods : Synchronized : Thread C# Examples


C# Examples » Thread » Synchronized »

 

Using synchronized methods









    
using  System;
using  System.Collections.Generic;
using  System.Diagnostics;
using  System.IO;
using  System.Reflection;
using  System.Runtime;
using  System.Runtime.CompilerServices;
using  System.Security;
using  System.Text;
using  System.Threading;

public  class  MainClass
{
        private  static  int  count  =  0;
        private  static  object  myMutex  =  new  object();
        
        [MethodImpl(MethodImplOptions.Synchronized)]
        public  static  void  Main()
        {
                  count++;

        }
}
    
   
  
   




HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Thread
» Synchronized