Monday, January 11, 2010
01-08-2010
I thought about my "problem" with Spring exiting on its thread and I'm thinking it really isn't a problem. It would be artificial for the launcher to spin in an infinite loop waiting for the application to be told to shutdown. I'm thinking that instead something inside Spring, such as Quartz, starts some sort of loop that keeps Spring from exiting. The question then becomes, how can I communicate to that "loop" that we do want to shutdown? It turns out that I had to put a sleep loop in the object that launches Spring. It wakes up every so often to see if its thread has been interrupted. If it has, it exits the loop. When a shutdown is issued by the client, the handler tells the Executor object to shutdown which sends an interrupt to all the threads associated with it. If each Runnable on those threads can detect the interruption everything gets shut down cleanly. Quartz does not appear to block the entire application as I thought it might.
Subscribe to:
Post Comments (Atom)

No comments:
Post a Comment