杂(jvm线程栈分析、jdkbug引发socketRead0阻塞、jvm调优等)
373个这样处于WAITING的http-nio-8081-exec线程
"http-nio-8081-exec-385" #459 daemon prio=5 os_prio=0 tid=0x00007f4b6819a800 nid=0x674e waiting on condition [0x00007f4b2e977000]
java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
用的AbstractQueuedSynchronizer的NonfairSync机制,看来当前线程还没拿到锁,阻塞等待持有锁的线程释放掉锁,然后跟其他线程一起抢锁
- parking to wait for <0x00000006c8ddb088> (a java.util.concurrent.locks.ReentrantLock$NonfairSync)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:836)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireQueued(AbstractQueuedSynchronizer.java:870)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2083)
从任务队列里拿一个任务,poll如果没拿到(任务队列为空)则返回null,否则先加锁,再拿任务,拿完把锁释放掉。锁的话是ReentrantLock
at java.util.concurrent.LinkedBlockingQueue.poll(LinkedBlockingQueue.java:467)
at org.apache.tomcat.util.threads.TaskQueue.poll(TaskQueue.java:85)
at org.apache.tomcat.util.threads.TaskQueue.poll(TaskQueue.java:31)
要去获得执行什么任务了
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1073)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1134)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
任务线程tashThread run
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)
一个处于RUNNABLE的线程,JDK的BUG ?!
"http-nio-8081-exec-386" #461 daemon prio=5 os_prio=0 tid=0x00007f4b74511000 nid=0x683f runnable [0x00007f4b2e773000]
java.lang.Thread.State: RUNNABLE
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.socketRead(SocketInputStream.java:116)
at java.net.SocketInputStream.read(SocketInputStream.java:171)
at java.net.SocketInputStream.read(SocketInputStream.java:141)
https://www.cnblogs.com/bestruggle/p/9836749.html
https://www.cnblogs.com/lcxdever/p/7481912.html
https://bugs.java.com/bugdatabase/view_bug.do?bug_id=jdk-8075484
该bug摘要信息:
JDK-8075484
SocketInputStream.socketRead0 can hang even with soTimeout set
Export
Details
Type: Bug
Status:RESOLVED
Priority: P3
Resolution: Fixed
Affects Version/s:
8u40
Fix Version/s:
9
Component/s:
core-libs
Labels:
7bpr-critical-approved CPU17_04-critical-SQE-OK CPU17_04-critical-approved noreg-hard webbug
Subcomponent: java.net
Resolved In Build: b137
CPU:
x86_64
OS:
linux
jvm调优
https://zhuanlan.zhihu.com/p/62762455
小绿书有空要看看