JRE 만있는 스레드 덤프를 얻으려면 동일한 Java 버전의 JDK에서 tools.jar 및 attach.dll이 필요합니다. 이것을 어딘가에 설치하고 이것을 jre에 복사하십시오. 동일한 버전이어야합니다!
시스템 계정에서 실행중인 프로세스의 덤프가 필요한 경우 Windows sysinternals psexec.exe를 사용하여 프로세스에 액세스 할 수 있습니다. 이것을 JRE bin이나 경로의 어딘가에 복사하십시오.
이 배치 파일은 파일 이름이 datetime 인 파일에 스택 덤프를 작성하므로 여러 추적을 쉽게 비교하고 비교할 수 있습니다.
그냥 참조를 위해, "죽일 -3 PID"
:: Creates a thread dump for the tomcat6.exe process
:: saved in a timestamped filename and views it!
:: Jim Birch 20111128 rev 2015-10-12
::Required the following files to be placed in the jre/bin folder:
:: attach.dll - From the Java JDK (must be the same version)
:: tools.jar - ditto
:: psexec.exe - from Windows sysinternals
::cd to jre/bin
d:
cd \application\jre\bin
::build datetime filename
rem datetime from wmi.exe
for /f "tokens=2 delims==" %%I in ('wmic os get localdatetime /format:list') do set dt0=%%I
rem datetime string as YYYY-MM-DD-hhmmss
set dt=%dt0:~0,4%-%dt0:~4,2%-%dt0:~6,2%-%dt0:~8,6%
set ff=td-%dt%.txt
echo filename: %ff%
::PID of the process by named exe, eg, tomcat6
for /F "tokens=2" %%I in ('TASKLIST /NH /FI "IMAGENAME eq tomcat6.exe"') DO SET PID=%%I
echo pid: %PID%
::combine above with jstack command
psexec -s jstack.exe -l %PID% >> %ff%
:: view result
start %ff%
::insert pause to debug or timer to review script operation
::ping localhost -n 20 >nul
::pause
Threads.bat 표준 출력에 전체 스레드 스택 추적을 덤프 유닉스/리눅스 JRE의 원인이됩니다. 매우, 매우, 매우 편리합니다. –