ThreadPoolExecutor not terminating
Mike McGrady
mmcgrady at topiatechnology.com
Mon Jul 20 21:41:05 EDT 2009
The ThreadPoolExecutor from ExcutorUtil is shutting down but is not
terminating, resulting in releaseExternalResources from
NioClientSocketChannelFactory not returning.
I know this functionality works. Of course it does!
The shutdownNow is returning an empty list of task waiting to be executed.
Any ideas? The repetition I am getting in a "debugged" ExecutorUtil is:
i = 1
Start: http://localhost:8080
Channel bound: true
RELEASE-1
Channel future success : true
Channel future done : true
Channel future cancelled: false
----End (Milliseconds: 862)
RELEASE-2: executors length: 2
EXECUTORS: [Ljava.util.concurrent.Executor;@114025
EXECUTOR: java.util.concurrent.ThreadPoolExecutor at 8a52b6
EXECUTOR: java.util.concurrent.ThreadPoolExecutor at 3c550f
RELEASE-3
RELEASE-3
RELEASE-4
RELEASE-4B: es = java.util.concurrent.ThreadPoolExecutor at 8a52b6
RELEASE-4C
RELEASE-4C1: SHUTDOWN NOW: java.util.concurrent.ThreadPoolExecutor at 8a52b6
LIST: []
shutdown: true
terminated: false
RELEASE-4D
----------YES
shutdown: true
terminated: true
RELEASE-4
RELEASE-4B: es = java.util.concurrent.ThreadPoolExecutor at 3c550f
RELEASE-4C
RELEASE-4C1: SHUTDOWN NOW: java.util.concurrent.ThreadPoolExecutor at 3c550f
LIST: []
shutdown: true
terminated: false
RELEASE-4D
----------NO
This is for the ExecutorUtil code:
for (Executor e: executorsCopy) {
System.out.println("RELEASE-4") ;
if (!(e instanceof ExecutorService)) {
System.out.println("RELEASE-4A") ;
continue;
}
ExecutorService es = (ExecutorService) e;
System.out.println("RELEASE-4B: es = " + es) ;
for (;;) {
System.out.println("RELEASE-4C") ;
try {
List waiting = es.shutdownNow();
System.out.println("RELEASE-4C1: SHUTDOWN NOW: " + es + "
LIST: " + waiting) ;
System.out.println("shutdown: " + es.isShutdown()) ;
System.out.println("terminated: " + es.isTerminated()) ;
} catch (SecurityException ex) {
// Running in a restricted environment - fall back.
try {
es.shutdown();
System.out.println("RELEASE-4C2: SHUTDOWN: " + es) ;
} catch (SecurityException ex2) {
// Running in a more restricted environment.
// Can't shut down this executor - skip to the next.
System.out.println("+++++++++++++++SHOULDN'T?-0") ;
break;
} catch (NullPointerException ex2) {
// Some JDK throws NPE here, but shouldn't.
System.out.println("SHOULDN'T?-1") ;
}
} catch (NullPointerException ex) {
// Some JDK throws NPE here, but shouldn't.
System.out.println("SHOULDN'T?-2") ;
}
System.out.println("RELEASE-4D") ;
try {
if (es.awaitTermination(100, TimeUnit.MILLISECONDS)) {
System.out.println("----------YES") ;
System.out.println("shutdown: " + es.isShutdown()) ;
System.out.println("terminated: " + es.isTerminated())
;
break;
} else {
System.out.println("----------NO") ;
}
} catch (InterruptedException ex) {
System.out.println("IGNORE?") ;
// Ignore.
}
System.out.println("RELEASE-4E shutdown: " + es.isShutdown()) ;
if (es.isShutdown()) {
System.out.println("IS SHUTDOWN") ;
}
System.out.println("RELEASE-4E terminated: " +
es.isTerminated()) ;
//System.out.println("RELEASE-4E terminating: " +
((ThreadPoolExecutor)es).isTerminating() ;
}
}
System.out.println("RELEASE END") ;
--
View this message in context: http://n2.nabble.com/ThreadPoolExecutor-not-terminating-tp3293084p3293084.html
Sent from the Netty User Group mailing list archive at Nabble.com.
More information about the netty-users
mailing list