關於專案中的執行緒的堆疊詳細資訊,利用jsp頁面來實現。
在實際的專案中我們通過Thread.getAllStacktraces()方法進行檢視相關的資訊。這樣可以隨時方便的管理檢視程式中的執行緒的相關資訊
<%@ page language="java" contentType="text/html; charset=utf-8"
import="java.util.Map"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>伺服器執行緒</title>
</head>
<body>
<pre>
<%
for (Map.Entry<Thread, StackTraceElement[]> strack :Thread.getAllStackTraces().entrySet()) {
Thread thread = strack.getKey();
StackTraceElement[] se = strack.getValue();
if(thread.equals(Thread.currentThread())) {
continue;
}
out.print("\n執行緒:" + thread.getName() + "\n");
for(StackTraceElement ele: se) {
out.print("\t" + ele + "\n");
}
}
%>
</pre>
</body>
</html>