java - Daemon Thread prevents JVM from terminating - possible reasons? -


i need develop maven plugin can start apache ftp-server, run daemon (does not halt build process) , stop goal. unfortunately first attempt daemon threads fails:

public class ftpserverdaemon {     public static void main(final string[] args) throws exception     {         thread thread = new thread(new runnable()                 {                     @override public void run()                     {                         org.apache.ftpserver.main.daemon.main(args);                     }                 });          thread.setdaemon(true);         thread.start();         thread.sleep(10000);     } } 

the bad thing here jvm not terminate after 10 seconds runs indefinitely. if daemon.main black-box code (however source available), can prevent jvm terminating in daemon thread?

agree assylias , chrylis comments.

instead of org.apache.ftpserver.main.daemon.main(args); can try other code there? loop lasts more time main thread sleeps should do, printing number every n seconds or something.

i believe must terminate properly. test whether ftpserver preventing exit.

by way, if daemon thread spawns child thread, child threads automatically set daemon, right? why might happening?


Comments