Use Monitors : Monitor : Thread C# Examples


C# Examples » Thread » Monitor »

 

Use Monitors









    
using  System;
using  System.Collections;
using  System.Threading;

class  MainClass
{
    public  static  ArrayList  MyList  =  new  ArrayList();
    
    static  void  Main(string[]  args)
    {
            Thread  ThreadOne  =  new  Thread(new  ThreadStart(MonitorExample));
        ThreadOne.Start();
    }
    static  void  MonitorExample()
    {
        Monitor.Enter(MyList);
        MyList.Add("a  value");
        Monitor.Exit(MyList);
    }
}
    
   
  
   




HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Thread
» Monitor