using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; namespace MultiThreading { class Program { static void Main(string[] args) { Operations op = new Operations(); Thread Th1 = new Thread(new ThreadStart(op.Op1)); Thread Th2 = new Thread(new ThreadStart(op.Op2)); //Thread Th3 = new Thread(new ThreadStart(op.Op3)); Th1.Start(); Th2.Start(); //Th3.Start(); Console.ReadLine(); } } class Operations { public void Op1() { Console.WriteLine("Thread 1 operation A"); Thread.Sleep(2000); Op3(); Console.WriteLine("Thread 1 operation B"); Thread.Sleep(2000); Op3(); Console.WriteLine("Thread 1 operation C"); } public void Op2() { Console.WriteLine("Thread 2 operation A"); Thread.Sleep(2000); Console.WriteLine("Thread 2 operation B"); Thread.Sleep(2000); Console.WriteLine("Thread 2 operation C"); } public void Op3() { Console.WriteLine("Do Nothing"); } } }
Thread 1 operation A Thread 2 operation A Thread 2 operation B Do Nothing Thread 1 operation B Do Nothing Thread 1 operation C Thread 2 operation C
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)