JVM TI学习----如何中断weblogic中stuck thread
2009-09-22 00:00:00 来源:WEB开发网曾经不止一次的被客户问道我们能否中断这样的线程,从weblogic层面来看,这是mission impossible。现在有了TI,我们可以通过它中断这样的线程。
要中断这样的线程,首先要借助thread dump拿到线程名,我们将以线程名为filter。Thread dump信息如下:
"[ACTIVE] ExecuteThread: '2' for queue: 'weblogic.kernel.Default (self-tuning)'" daemon prio=6 tid=0x2b25a800 nid=0x3c0 waiting on condition [0x2e08f000..0x2e08fa14]
java.lang.Thread.State: TIMED_WAITING (sleeping)
at java.lang.Thread.sleep(Native Method)
......
上面这个线程的名字就是:[ACTIVE] ExecuteThread: '2' for queue: 'weblogic.kernel.Default (self-tuning)'
为了能正确的attach上JVM,启动的时候需要加上如下的JAVA_OPTIONS,
-Xdebug -Xrunjdwp:transport=dt_socket,address=9191,server=y,suspend=n
现在我们就可以下面的方法attach到target JVM,
1 private VirtualMachine connectVM(){
2 VirtualMachineManager vmm = Bootstrap.virtualMachineManager();
3 List connectors = vmm.attachingConnectors();
4 Connector conn = null;
5 AttachingConnector socketAttachingConnector = null;
6 /*
7 * host and port should be set here
8 */
9 .
10 try{
11 vm = socketAttachingConnector.attach(arguments);
12 }catch(Exception e){
13 e.printStackTrace();
14 }
15 return this.vm;
16 }
更多精彩
赞助商链接