Author: jaz
Date: Thu May 10 18:04:35 2007
New Revision: 537058
URL:
http://svn.apache.org/viewvc?view=rev&rev=537058Log:
now dumps a thread list on shutdown
Modified:
ofbiz/trunk/framework/base/src/base/org/ofbiz/base/container/ContainerLoader.java
Modified: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/container/ContainerLoader.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/container/ContainerLoader.java?view=diff&rev=537058&r1=537057&r2=537058==============================================================================
--- ofbiz/trunk/framework/base/src/base/org/ofbiz/base/container/ContainerLoader.java (original)
+++ ofbiz/trunk/framework/base/src/base/org/ofbiz/base/container/ContainerLoader.java Thu May 10 18:04:35 2007
@@ -22,6 +22,8 @@
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
+import java.io.PrintWriter;
+import java.io.StringWriter;
import org.ofbiz.base.start.StartupException;
import org.ofbiz.base.start.StartupLoader;
@@ -91,7 +93,7 @@
*/
public void unload() throws StartupException {
Debug.logInfo("Shutting down containers", module);
-
+ printThreadDump();
// shutting down in reverse order
for (int i = loadedContainers.size(); i > 0; i--) {
Container container = (Container) loadedContainers.get(i-1);
@@ -101,6 +103,32 @@
Debug.logError(e, module);
}
}
+ }
+
+ private void printThreadDump() {
+ Thread currentThread = Thread.currentThread();
+ ThreadGroup group = currentThread.getThreadGroup();
+ while (group.getParent() != null) {
+ group = group.getParent();
+ }
+ Thread threadArr[] = new Thread[1000];
+ group.enumerate(threadArr);
+
+ StringWriter writer = new StringWriter();
+ PrintWriter out = new PrintWriter(writer);
+ out.println("Thread dump:");
+ for (int i = 0; i < threadArr.length; i++) {
+ if (threadArr[i] != null) {
+ ThreadGroup g = threadArr[i].getThreadGroup();
+ out.println("Thread: " + threadArr[i].getName() + " [" + threadArr[i].getId() + "] @ " + (g != null ? g.getName() : "[none]") + " : " + threadArr[i].getPriority() + " [" + threadArr[i].getState().name() + "]");
+ out.println("--- Alive: " + threadArr[i].isAlive() + " Daemon: " + threadArr[i].isDaemon());
+ StackTraceElement[] stacks = threadArr[i].getStackTrace();
+ for (int x = 0; x < stacks.length; x++) {
+ out.println("### " + stacks[x].toString());
+ }
+ }
+ }
+ Debug.logInfo(writer.toString(), module);
}
private Container loadContainer(ContainerConfig.Container containerCfg, String[] args) throws StartupException {