0311_C#キューQueue

827 ワード

 class Program
    {
        static Queue q = new Queue();
        static void Main(string[] args)
        {
            // 1.     ,    
            //          
            Thread th = new Thread(new ThreadStart(printQueue));
            th.Start();

            // 2.   ,    
            //  Web      ,     ,   
            while (true)
            {
                string str = Console.ReadLine();
                q.Enqueue(str);
            }
            Console.Read();
        }

        static private void printQueue()
        {
            while (true)
            {
                if (q.Count > 0)
                {
                    string str = q.Dequeue();
                    Console.WriteLine(str);
                }
            }
        }
    }