public static void Run() { Console.WriteLine("main thread starting worker thread..."); ConcurrentBuffer cb = new ConcurrentBuffer(10); Producer p = new Producer(cb); Consumer c = new Consumer(cb); Thread p1 = new Thread(p.Produce); Thread c1 = new Thread(c.Consume); p1.Start(); c1.Start(); Console.WriteLine("main thread sleeping for 1 second..."); Thread.Sleep(1000); Console.WriteLine("main thread done."); }
public Producer(ConcurrentBuffer buffer) { this.buffer = buffer; }
public Consumer(ConcurrentBuffer buffer) { this.buffer = buffer; }