Exemplo n.º 1
0
        static void Main(string[] args)
        {
            Stopwatch s1 = new Stopwatch();

            s1.Start();

            Boundedbuffer buf = new Boundedbuffer(4);

            Producer prod = new Producer(buf, 100);
            Consumer con  = new Consumer();

            Parallel.Invoke(prod.run, con.Run);
            s1.Stop();
            Console.WriteLine("tid" + s1.Elapsed);
            Console.ReadKey();
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            Stopwatch s1 = new Stopwatch();
            s1.Start();

            Boundedbuffer buf = new Boundedbuffer(10);

            Producer prod = new Producer(buf, 100);
            Consumer con = new Consumer(buf, 100);


            Parallel.Invoke(prod.run, con.Run);
            s1.Stop();
            Console.WriteLine("tid" + s1.Elapsed);
            Console.ReadKey();


            


        }
Exemplo n.º 3
0
 public Producer(Boundedbuffer buffer, int howManyToProduce)
 {
     this._max    = howManyToProduce;
     this._buffer = buffer;
 }
Exemplo n.º 4
0
 public Consumer(Boundedbuffer buffer, int expectedAmount)
 {
     this._buffer = buffer;
     this._max    = expectedAmount;
 }
Exemplo n.º 5
0
 public Consumer(Boundedbuffer buffer, int expectedAmount)
 {
     this._buffer = buffer;
     this._max = expectedAmount;
 }
Exemplo n.º 6
0
 public Producer(Boundedbuffer buffer, int howManyToProduce)
 {
     this._max = howManyToProduce;
     this._buffer = buffer;
 }