public static void Main(string[] str) { CNum cnum = new CNum(); Object common_lock = new Object(); GeneratNum genrate = new GeneratNum(cnum, common_lock); Consumer consum = new Consumer(cnum, common_lock);//0 Consumer1 consum1 = new Consumer1(cnum, common_lock); Consumer2 consum2 = new Consumer2(cnum, common_lock); Consumer3 consum3 = new Consumer3(cnum, common_lock); Thread t1 = new Thread(genrate.Generate); Thread t2 = new Thread(consum.Consume); Thread t3 = new Thread(consum1.Consume); Thread t4 = new Thread(consum2.Consume); Thread t5 = new Thread(consum3.Consume); Console.WriteLine(" Number\t Even Odd \t Prime\t Fabonacci"); t1.Start(); //Thread.Sleep(1000); t2.Start(); t3.Start(); t4.Start(); t5.Start(); Console.ReadKey(); }
public Consumer(CNum cnum, object common_lock) { // TODO: Complete member initialization this.cnum = cnum; this.common_lock = common_lock; }