diff -r ed84c8bdd87b -r f8894df2d079 src/org/sonews/ShutdownHook.java --- a/src/org/sonews/ShutdownHook.java Sun Aug 29 17:28:58 2010 +0200 +++ b/src/org/sonews/ShutdownHook.java Wed May 04 18:06:24 2011 +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."); + } }