Created
March 15, 2012 00:57
-
-
Save taka2/2040833 to your computer and use it in GitHub Desktop.
デーモンスレッドにして、プロセスが終わるようにした。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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