views:

29

answers:

1

Hi, I have an application that spawns worker threads and process files in the the worker threads. On application shutdown request, I want the application to shutdown only when the worker thread has finished processing the current file (if it is processing a file). I am using JavaServiceWarapper to manage my application.

I have added shutdown hooks that informs the worker thread not to start processing a new file when it gets a shutdown request.

Processing a file never takes more than 30 seconds and I have set the time outs to 60 seconds, just to be one safe side.

For some reason, when I trigger stop, my application shuts down immediately and doesnt wait for the worker threads to complete. The worker threads get the shutdown request but the application exits immediately (and doesnt wait for 60 secs)

Some of the important settings I have wrapper.java.mainclass=org.tanukisoftware.wrapper.WrapperSimpleApp wrapper.adviser=FALSE wrapper.debug=FALSE wrapper.disablerestarts=FALSE wrapper.jvmexit.timeout=60 wrapper.requestthreaddumponfailedjvmexit=TRUE wrapper.shutdown.timeout=60 wrapper.signal.mode.hup=FORWARD wrapper.startup.timeout=300 wrapper.usesystemtime=FALSE wrapper.ping.timeout=120

Can anyone help me with the mistake I am doing.

A: 

You didn't happen to start all your worker threads as daemons, did you? if so, the VM will consider the work they're doing inconsequential and die despite the fact that they're still working..

from the JavaDocs of Thread.setDaemon(): "The Java Virtual Machine exits when the only threads running are all daemon threads."

try to setDaemon(false) before you start the Thread and see if that helps.

saleemshafi
Hi Saleem,I have all the worker threads as non-daemon. That didnt help :(