// 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; namespace E { public class T1 { private string s; public T1(string s) { this.s = s; } public void Run() { Console.WriteLine(s); } } public class T2 { public static void Run(object s) { Console.WriteLine((string)s); } } public class Program { public static void Main(string[] args) { Thread t1 = new Thread(new ThreadStart((new T1("ABC")).Run)); t1.Start(); t1.Join(); Thread t2 = new Thread(new ParameterizedThreadStart(T2.Run)); t2.Start("DEF"); t2.Join(); Thread t1x = new Thread((new T1("GHI")).Run); t1x.Start(); t1x.Join(); Thread t2x = new Thread(T2.Run); t2x.Start("JKL"); t2x.Join(); Thread t3 = new Thread(delegate(object s) { Console.WriteLine((string)s); }); t3.Start("MNO"); t3.Join(); Thread t4 = new Thread((object s) => Console.WriteLine((string)s)); t4.Start("PQR"); t4.Join(); } } }