diff -r c404a87db5b7 -r 74139325d305 src/org/sonews/ShutdownHook.java --- a/src/org/sonews/ShutdownHook.java Sun Aug 29 17:43:58 2010 +0200 +++ b/src/org/sonews/ShutdownHook.java Sun Aug 29 18:17:37 2010 +0200 @@ -30,55 +30,44 @@ class ShutdownHook extends Thread { - /** - * Called when the JVM exits. - */ - @Override - public void run() - { - System.out.println("sonews: Trying to shutdown all threads..."); + /** + * Called when the JVM exits. + */ + @Override + public void run() + { + System.out.println("sonews: Trying to shutdown all threads..."); - Map threadsMap = Thread.getAllStackTraces(); - for(Thread thread : threadsMap.keySet()) - { - // Interrupt the thread if it's a AbstractDaemon - AbstractDaemon daemon; - if(thread instanceof AbstractDaemon && thread.isAlive()) - { - try - { - daemon = (AbstractDaemon)thread; - daemon.shutdownNow(); - } - catch(SQLException ex) - { - System.out.println("sonews: " + ex); - } - } - } - - for(Thread thread : threadsMap.keySet()) - { - AbstractDaemon daemon; - if(thread instanceof AbstractDaemon && thread.isAlive()) - { - daemon = (AbstractDaemon)thread; - System.out.println("sonews: Waiting for " + daemon + " to exit..."); - try - { - daemon.join(500); - } - catch(InterruptedException ex) - { - System.out.println(ex.getLocalizedMessage()); - } - } - } - - // We have notified all not-sleeping AbstractDaemons of the shutdown; - // all other threads can be simply purged on VM shutdown - - System.out.println("sonews: Clean shutdown."); - } - + Map threadsMap = Thread.getAllStackTraces(); + for (Thread thread : threadsMap.keySet()) { + // Interrupt the thread if it's a AbstractDaemon + AbstractDaemon daemon; + if (thread instanceof AbstractDaemon && thread.isAlive()) { + try { + daemon = (AbstractDaemon) thread; + daemon.shutdownNow(); + } catch (SQLException ex) { + System.out.println("sonews: " + ex); + } + } + } + + for (Thread thread : threadsMap.keySet()) { + AbstractDaemon daemon; + if (thread instanceof AbstractDaemon && thread.isAlive()) { + daemon = (AbstractDaemon) thread; + System.out.println("sonews: Waiting for " + daemon + " to exit..."); + try { + daemon.join(500); + } catch (InterruptedException ex) { + System.out.println(ex.getLocalizedMessage()); + } + } + } + + // We have notified all not-sleeping AbstractDaemons of the shutdown; + // all other threads can be simply purged on VM shutdown + + System.out.println("sonews: Clean shutdown."); + } }