// FYI, here's an example of threads and simple synchronization in C# .Net. // Unlike Java, .Net threads are based on functions as opposed to objects. // However, like Java, synchronization mechanisms are based on objects. using System; using System.Threading; public class someclass { public int x = 10; // shared by different threads public void f() { Console.WriteLine("thread started ..."); for (int i=0;i<10000000;i++) { Monitor.Enter(this); // synchronize on this object x++; x--; x++; x--; x++; x=x+2; x = x-3; // critical section Monitor.Exit(this); } Console.WriteLine("thread exiting."); } } public class threadsynch { public static void Main() { int i; int n = 20; // number of threads someclass myobject = new someclass(); Thread[] T = new Thread[n]; // array of thread pointers for(i=0;i