コード例 #1
0
        public static void Main(string[] args)
        {
            PC pc = new PC();

            Thread t1 = new Thread(new ThreadStart(() => {
                try {
                    pc.Produce();
                } catch (Exception) {
                    throw;
                }
            }));

            Thread t2 = new Thread(new ThreadStart(() => {
                try {
                    pc.Consume();
                } catch (Exception) {
                    throw;
                }
            }));

            t1.Start();
            t2.Start();

            t1.Join();
            t2.Join();
        }