flag
-
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을 발동 ..