Exemple #1
0
        static void Main(string[] args)
        {
            Lolz <string>  tehLolz  = new Lolz <string>();
            object         locker   = new object();
            ProduceTehLolz producer = new ProduceTehLolz(tehLolz, locker);
            ConsumeTehLolz consumer = new ConsumeTehLolz(tehLolz, locker);

            Thread[] threads = new Thread[2];
            threads[0] = new Thread(producer.produce);
            threads[1] = new Thread(consumer.consume);
            threads[0].Start();
            threads[1].Start();
            threads[0].Join();
            threads[1].Join();
            Console.ReadKey();
        }
 public ProduceTehLolz(Lolz <string> lolz, object locker)
 {
     tehLolz   = lolz;
     tehLock   = locker;
     lolRandom = new Random();
 }
 public ConsumeTehLolz(Lolz <string> lolz, object locker)
 {
     tehLolz = lolz;
     tehLock = locker;
 }