You can mark the stream as a daemon using the provided setDaemon method. According to java doc:
Marks this thread as a daemon thread or user thread. The Java virtual machine exits when all threads executed only by a thread are daemon threads.
This method must be called before the stream begins.
This method first calls the checkAccess method of this stream with no arguments. This can throw a SecurityException (in the current thread).
Here is an example:
Thread someThread = new Thread(new Runnable() { @Override public void run() { runSomething(); } }); someThread.setDaemon(true); someThread.start();
amoran
source share