// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.Threading; public class T { private static Random rng = new Random(); private int n; public T() { n = 0; } public void Run() { while(true) { Thread.Sleep(rng.Next(100)); n++; } } public int N { get { return n; } } } class MainClass { public static void Main(string[] args) { T[] t = new T[4]; for(int i = 0; i < t.Length; i++) { t[i] = new T(); } for(int i = 0; i < t.Length; i++) { (new Thread(new ThreadStart(t[i].Run))).Start(); } while(true) { for(int i = 0; i < t.Length; i++) { Console.Write(" " + t[i].N); } Console.WriteLine(); Thread.Sleep(1000); } } }