반응형
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

namespace Thread_연습
{
    public class Shape
    {
        private volatile bool print;
        public void Print()
        {
            while (!print)
            {
                Console.WriteLine("룰루 랄라~ 룰루랄라~");
            }
            Console.WriteLine("집에 가자~");
            
        }
        public void Stop()
        {
            print = true;
        }

        
    
    }
    class Program
    {
        static void Main(string[] args)
        {
            Shape sp = new Shape();
            Thread ShapeThread = new Thread(sp.Print);


            ShapeThread.Start();
            while (!ShapeThread.IsAlive) ;

            Thread.Sleep(10);

            sp.Stop();

            Console.WriteLine("끝~");


        }
    }
}




반응형

'프로그래밍 > Language C#' 카테고리의 다른 글

[C#] DB 연동  (0) 2011.12.23
[C#] Thread 실습  (0) 2011.11.17
[C#] 전화번호부 2탄 (List,IEnumberable 적용,클래스 상속)  (0) 2011.11.14
[C#] 전화번호 저장  (0) 2011.11.14
[C#] Sort(Collection)  (0) 2011.11.10