<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8"%>
<%@ page import="java.util.Set"%>
<%@ page import="java.util.Map"%>
<%@ page import="java.util.Iterator"%>
<%
if("127.0.0.1".equals(request.getRemoteHost()))
{
Map<Thread,StackTraceElement[]> threads = Thread.getAllStackTraces();
Set keys = threads.keySet();
Iterator iter = keys.iterator();
while (iter.hasNext())
{
Thread t = (Thread)iter.next();
%>
ID: <%=t.getId()%>
State: <%=t.getState()%>
<%= "\n"%>
<%
StackTraceElement[] trace = threads.get(t);
for(int i = 0 ;i < trace.length;i++)
{
%>
<%= trace[i].toString()%>
<%= "\n"%>
<%
}
}
}
%>
如果不是本地测试,请将if("127.0.0.1".equals(request.getRemoteHost()))分支去掉,使用浏览器访问该页面,然后通过“查看源文件”查看内存堆栈情况。
<%@ page import="java.util.Set"%>
<%@ page import="java.util.Map"%>
<%@ page import="java.util.Iterator"%>
<%
if("127.0.0.1".equals(request.getRemoteHost()))
{
Map<Thread,StackTraceElement[]> threads = Thread.getAllStackTraces();
Set keys = threads.keySet();
Iterator iter = keys.iterator();
while (iter.hasNext())
{
Thread t = (Thread)iter.next();
%>
ID: <%=t.getId()%>
State: <%=t.getState()%>
<%= "\n"%>
<%
StackTraceElement[] trace = threads.get(t);
for(int i = 0 ;i < trace.length;i++)
{
%>
<%= trace[i].toString()%>
<%= "\n"%>
<%
}
}
}
%>
如果不是本地测试,请将if("127.0.0.1".equals(request.getRemoteHost()))分支去掉,使用浏览器访问该页面,然后通过“查看源文件”查看内存堆栈情况。