interrupted
-
Java - Deamon Thread, Thread GroupJava 2018. 1. 31. 13:14
// deamon thread는 main thread작업을 돕는 보조적인 역할을 수행 한다.// Work Thread와 마찬가지로 main thread에 의해서 생성 된다// 다만 life cycle의 차이가 있다. // deamon thread는 main thread가 끝날때 같이 끝난다.// Work thread는 작업이 다 끝나야 thread가 끝난다. public class DeamonThread extends Thread { @Override public void run() { while(true) { try { Thread.sleep(500); System.out.println("Thread Working..."); } catch (InterruptedExcept..
-
Java - Stop, InterruptJava 2018. 1. 31. 12:07
public class StopFlag extends Thread { boolean stop = false; @Override public void run() { while(!stop) { System.out.println("Thread Running..."); } System.out.println("종료"); } } public class Main { public static void main(String[] args) throws InterruptedException { StopFlag stop = new StopFlag(); stop.start(); Thread.sleep(1000); stop.stop = true; } } // InterruptedException을 발동 ..