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:
Related in same category :
-
-
-
-
-
-
-
-
|