sleep
-
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을 발동 ..
-
Java - ThreadJava 2018. 1. 30. 14:57
// Thread는 어떤 program을 실행 하게 해주는 원동력이다// 대표적으로 main(String[] args)로 실행 한다. // process는 1개 이상의 thread로 구성되어 있다.// process는 thread로 구성 된다.// 메모리 공유 부분에서 process는 메모리 공유가 안되지만,// Thread는 메모리 공유가 된다. // main method는 main thread를 생성 한다.// 처리가 버거우면 work thread를 생성할 수 있다.// 이것을 multi thread라 한다. // Runnable Interface, Thread Class 상속으로 생성할 수 있다. public class Main { public static void main(..