Skip to content

Instantly share code, notes, and snippets.

@wicksome
Created August 2, 2014 15:30
Show Gist options
  • Save wicksome/6f81c443dd4672cc3eb1 to your computer and use it in GitHub Desktop.
Save wicksome/6f81c443dd4672cc3eb1 to your computer and use it in GitHub Desktop.
데몬 쓰레드 예제
public class DaemonThread implements Runnable {
public static void main(String[] args) {
Thread th = new Thread(new DaemonThread());
th.setDaemon(true);
th.start();
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println("Main thread terminated...");
}
@Override
public void run() {
while (true) {
System.out.println("is running...");
try {
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
break;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment