JAVA Basic 강의자료] stop을 이용한 쓰레드 종료 예제

 

JAVA Basic 강의자료] stop을 이용한 쓰레드 종료 예제

 

 

 

 

실무개발자를위한 실무교육 전문교육센터학원
www.oraclejava.co.kr에 오시면 보다 다양한 강좌를 보실 수 있습니다.

 

 

 

stop을 이용한 쓰레드 종료 예제

 

 

<소스코드>

 

 

class ThreadEnd extends Thread {
    public void run() {
        while(true) {
            try {
                sleep(500);
            } catch( InterruptedException e ) { }
            System.out.println( getName() );
        }
    }

    public static void main(String[] args) {
        ThreadEnd thr = new ThreadEnd();
        thr.start();
        try {
            sleep(2000);
        } catch( InterruptedException e ) { }
        thr.stop();
    }
}

+ Recent posts