我正在调试实时环境,并且进行了一些线程转储。我看到很多线程都在“等待状态”;但是我怎么知道那是什么状况?
下面是真实的线程转储堆栈的片段:
"Uploader-pool-job-create-ca2d264a-51b3-4fa3-8113-
f0f0aca47add-StreamThread-10-0_14" #140 daemon prio=5 os_prio=0
tid=0x00007f006002b800 nid=0x18b waiting on condition
[0x00007f004d9e1000]
java.lang.Thread.State: TIMED_WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x00000002c20d4320> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:215)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2078)
at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1093)
at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:809)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1067)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1127)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
其他
:"Uploader-pool-job-create-ca2d264a-51b3-4fa3-8113-
f0f0aca47add-StreamThread-3-0_16" #138 daemon prio=5 os_prio=0
tid=0x00000000025da000 nid=0x189 waiting on condition
[0x00007f004dbe3000]
java.lang.Thread.State: TIMED_WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x00000002c20d6690> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:215)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2078)
at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1093)
at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:809)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1067)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1127)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
在这些线程中说的是“等待条件”;但是我无法解读线程正在等待的条件是什么?
->通常,是否有任何指南可以理解线程转储。
答案 0 :(得分:5)
这一切都在堆栈跟踪中-awaiting条件下,ScheduledThreadPoolExecutor
是available
:
private final Condition available;
. . .
available.awaitNanos(delay); // ScheduledThreadPoolExecutor.java:1093
换句话说,池中的线程处于空闲状态,正在等待更多工作。
通常,堆栈跟踪会准确显示执行线程当前所在的Java文件名和行号(通常在线程等待时,最深的几个级别太低了,因此只需继续执行即可)。链以找到最有意义的水平。
答案 1 :(得分:1)
在我看来,就像他们在等待获取锁一样。这种情况下的条件是:等待超时完成以尝试获取锁。
dependencies {
implementation 'com.jakewharton:butterknife:10.0.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.0.0'
}