X-Git-Url: http://dolda2000.com/gitweb/?p=jsvc.git;a=blobdiff_plain;f=src%2Fdolda%2Fjsvc%2FThreadContext.java;h=78a5d4e87578d5ce8e7b6445500ae31b75e56bc7;hp=f21d04ccb9f6221c9a4af564c325ce55ea453b0c;hb=a0b186f8f8342791c1d65ca8f04118b0d73d5bb8;hpb=c9837b5e87402fa1375fe6d3dd80cb3405edda42 diff --git a/src/dolda/jsvc/ThreadContext.java b/src/dolda/jsvc/ThreadContext.java index f21d04c..78a5d4e 100644 --- a/src/dolda/jsvc/ThreadContext.java +++ b/src/dolda/jsvc/ThreadContext.java @@ -24,9 +24,25 @@ public class ThreadContext extends ThreadGroup { } public void shutdown() { - interrupt(); if(root instanceof ContextResponder) ((ContextResponder)root).destroy(); + try { + long last = 0; + while(true) { + long now = System.currentTimeMillis(); + if(now - last > 10000) { + interrupt(); + last = now; + } + Thread[] th = new Thread[1]; + if(enumerate(th) < 1) + break; + th[0].join(10000); + } + } catch(InterruptedException e) { + logger.log(Level.WARNING, "Interrupted while trying to shut down all service threads. Some may remain.", e); + } + destroy(); } public RequestThread respond(Request req) {