Skip to content

Instantly share code, notes, and snippets.

@taka2
Created March 15, 2012 00:57
Show Gist options
  • Select an option

  • Save taka2/2040833 to your computer and use it in GitHub Desktop.

Select an option

Save taka2/2040833 to your computer and use it in GitHub Desktop.
デーモンスレッドにして、プロセスが終わるようにした。
public class test {
public static void main(String[] args) throws Exception {
Thread thread = new Thread(new Runnable() {
public void run() {
while(true) {
try {
System.out.println("Hello!");
Thread.sleep(1000);
} catch(InterruptedException e) {
// ignore
}
}
}
});
thread.setDaemon(true);
thread.start();
Thread.sleep(5000);
//System.exit(0);
throw new NoClassDefFoundError();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment