-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
193 additions
and
7 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
wine/src/main/java/com/wine/game/wine/common/DeadLock.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package com.wine.game.wine.common; | ||
/** | ||
* @description: | ||
# Codes are far away from bugs with the animal protecting | ||
# 神兽保佑,代码无bug | ||
* @author: zeno fung | ||
* | ||
* @create: 2022-07-26 10:25 | ||
*/ | ||
public class DeadLock { | ||
private static Integer resource1 = 1 ; | ||
private static Integer resource2 = 2 ; | ||
static class Thread1 implements Runnable{ | ||
@Override | ||
public void run() { | ||
synchronized (resource1){ | ||
try { | ||
System.out.println(getClass().getName()+" obtains the lock of resource1!"); | ||
Thread.sleep(500); | ||
synchronized (resource2) { | ||
System.out.println(getClass().getName()+" obtains the lock of resource2!"); | ||
} | ||
} catch (InterruptedException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
} | ||
} | ||
static class Thread2 implements Runnable{ | ||
@Override | ||
public void run() { | ||
synchronized (resource2){ | ||
try { | ||
System.out.println(getClass().getName()+" obtains the lock of resource2!"); | ||
Thread.sleep(500); | ||
synchronized (resource1) { | ||
System.out.println(getClass().getName()+" obtains the lock of resource1!"); | ||
} | ||
} catch (InterruptedException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
} | ||
} | ||
public static void main(String[] args) { | ||
new Thread(new Thread1()).start(); | ||
new Thread(new Thread2()).start(); | ||
} | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,5 +28,4 @@ public String getInfo(){ | |
return info; | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
|
||
|
||
命令: tail -100f localhost_access_log | ||
|
||
通过下面的命令查看实时的日志,执行完下面的查看日志的命令后,而后再次申请下程序,在日志中并没有发现申请记录,阐明tomcat处于一种假死状态,上面接着排查。 | ||
|
||
|
||
|
||
|
||
网络查看 | ||
CLOSE_WAIT过多情况 | ||
netstat -n | awk '/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}' | ||
|
||
netstat -an | grep "CLOSE_WAIT" | ||
|
||
ss -ant | ||
|
||
|
||
gc 情况查看 | ||
jstat -gcutil 【pid】 1000 | ||
|
||
|
||
gc 内存情况 | ||
jmap -heap 进程ID | ||
jmap -histo 进程ID | ||
|
||
|
||
|
||
①、应用 jstack 命令导出以后JVM的线程dump快照,而后看看dump中线程都在干什么? | ||
命令:jstack pid >> jvmThreadDump.log | ||
|
||
count=`cat jstack1.log | grep java.lang.Thread.State | wc -l`; wait=`cat jstack1.log | grep WAITING | wc -l`; a=`echo | awk "{print $wait/$count*100}"`; echo "$a%" | ||
|
||
|
||
|
||
|
||
一般针对内存泄露,除了开发代码的时候,就进行规范之后,等运行之后,要查看该问题,特别是线上环境的话,最好将完整的JVM堆栈信息给dump下来。这个时候可以使用以下命令: | ||
|
||
jmap -dump:file=heap-dump.bin 24118 | ||
|
||
指定为二进制文件 | ||
jmap -dump:format=b,file=heap-dump.bin <14365> | ||
|
||
|
||
|
||
tar -czvf li.zip.tar li | ||
tar -cvf archive_name.tar directory_to_compress |