예제 #1
0
        //public static int LastElement = -1;

        public Producer(BoundedBuffer buffer, int howMany)
        {
            if (buffer == null)
            {
                throw new ArgumentNullException("Buffer is null");
            }
            if (HowMany < 0)
            {
                throw new ArgumentOutOfRangeException("howMany is out of range");
            }
            Buffer  = buffer;
            HowMany = howMany;
        }
예제 #2
0
        //public static int LastElement = -1;

        public Producer(BoundedBuffer buffer, int howMany)
        {
            if (buffer == null)
            {
                throw new ArgumentNullException("Buffer is null");
            }
            if (HowMany < 0)
            {
                throw new ArgumentOutOfRangeException("howMany is out of range");
            }
            Buffer = buffer;
            HowMany = howMany;
        }
예제 #3
0
        static void Main(string[] args)
        {
            BoundedBuffer buffer = new BoundedBuffer(4);
            Producer producer = new Producer(buffer, 10000);
            Consumer consumer = new Consumer(buffer, 10000);
            
            Parallel.Invoke(producer.Run, consumer.Run);



            //Thread t1 = new Thread(() => producer.Run());
            //Thread t2 = new Thread(() => consumer.Run());
            //t1.Start();
            //t2.Start();
        }
예제 #4
0
        static void Main(string[] args)
        {
            BoundedBuffer buffer   = new BoundedBuffer(4);
            Producer      producer = new Producer(buffer, 10000);
            Consumer      consumer = new Consumer(buffer, 10000);

            Parallel.Invoke(producer.Run, consumer.Run);



            //Thread t1 = new Thread(() => producer.Run());
            //Thread t2 = new Thread(() => consumer.Run());
            //t1.Start();
            //t2.Start();
        }
예제 #5
0
 public Consumer(BoundedBuffer buffer, int howMany)
 {
     Buffer = buffer;
     HowMany = howMany;
 }
예제 #6
0
 public Consumer(BoundedBuffer buffer, int howMany)
 {
     Buffer  = buffer;
     HowMany = howMany;
 }