Пример #1
0
        static void Main(string[] args)
        {
            int writer = GetValue("Please enter to count threads for writer: ");

            int reader = GetValue("Please enter to count threads for reader: ");

            int sizeBuffer = GetValue("Please enter to length of buffer: ");

            circleBuffer = new CircleBuffer <int>(sizeBuffer);

            MyThread[] writers = new WriteBuffer[writer];

            MyThread[] readers = new ReadBuffer[reader];

            Random random = new Random();

            WriteBuffer.Count = random.Next(sizeBuffer, sizeBuffer * 4);

            for (int i = 0; i < writer; i++)
            {
                writers[i] = new WriteBuffer(new object( ));
                if (i == writer - 1)
                {
                    for (int j = 0; j < reader; j++)
                    {
                        readers[j] = new ReadBuffer(new object( ));
                    }
                }
            }
        }
Пример #2
0
 public MyThread(CircleBuffer <int> circleBuffer)
 {
     _thread = new Thread(Run);
     _thread.Start( );
 }