示例#1
0
        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.");
        }
示例#2
0
 public Producer(ConcurrentBuffer buffer)
 {
     this.buffer = buffer;
 }
示例#3
0
 public Consumer(ConcurrentBuffer buffer)
 {
     this.buffer = buffer;
 }