gpt4 book ai didi

java - 如何找出线程卡住的原因?

转载 作者:太空宇宙 更新时间:2023-11-04 14:35:35 25 4
gpt4 key购买 nike

我在 jstack 中看到该线程似乎根本没有移动。有关如何找出卡住原因的任何指示吗?我没有看到任何锁或任何东西,唯一可疑的是“Object.wait()”引用。

"main" prio=10 tid=0x00007f3a8000b000 nid=0x942 in Object.wait() [0x00007f3a89539000]
java.lang.Thread.State: RUNNABLE
at org.joda.time.DateTimeZone.<clinit>(DateTimeZone.java:95)
at org.joda.time.format.DateTimeFormatter.withZoneUTC(DateTimeFormatter.java:301)
at com.amazonaws.auth.AWS4Signer.<clinit>(AWS4Signer.java:44)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
at java.lang.Class.newInstance0(Class.java:372)
at java.lang.Class.newInstance(Class.java:325)
at com.amazonaws.auth.SignerFactory.createSigner(SignerFactory.java:121)
at com.amazonaws.auth.SignerFactory.lookupAndCreateSigner(SignerFactory.java:107)
at com.amazonaws.auth.SignerFactory.getSigner(SignerFactory.java:80)
at com.amazonaws.AmazonWebServiceClient.computeSignerByServiceRegion(AmazonWebServiceClient.java:311)
at com.amazonaws.AmazonWebServiceClient.computeSignerByURI(AmazonWebServiceClient.java:284)
at com.amazonaws.AmazonWebServiceClient.setEndpoint(AmazonWebServiceClient.java:160)

此外,堆栈顶部的 DateTimeZone.java 中的第 95 行是这样的:

   public static final DateTimeZone UTC = new FixedDateTimeZone("UTC", "UTC", 0, 0);

还有另一个线程也卡在类似的地方:

"FeatureManagerService" daemon prio=10 tid=0x00007f3a8056a800 nid=0x94f in Object.wait() [0x00007f3a84151000]
java.lang.Thread.State: RUNNABLE
at com.amazonaws.util.DateUtils.<clinit>(DateUtils.java:35)
at com.amazonaws.services.s3.internal.ServiceUtils.<clinit>(ServiceUtils.java:59)
at com.amazonaws.services.s3.internal.S3Signer.sign(S3Signer.java:123)
at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:348)
at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:245)
at com.amazonaws.services.s3.AmazonS3Client.invoke(AmazonS3Client.java:3711)
at com.amazonaws.services.s3.AmazonS3Client.invoke(AmazonS3Client.java:3664)
at com.amazonaws.services.s3.AmazonS3Client.listObjects(AmazonS3Client.java:620)
at com.amazonaws.services.s3.AmazonS3Client.listObjects(AmazonS3Client.java:603)

而 DateUtils.java:35 是:

private static final DateTimeZone GMT = new FixedDateTimeZone("GMT", "GMT", 0, 0);

我已经尝试使用 jvisualvm/jhat 来研究它,但并没有真正走得太远。

请注意,这是一个实时进程,而不是我在本地调试器中运行的进程,重新启动后它工作正常,因此它看起来是间歇性的。

如有任何帮助,我们将不胜感激!

谢谢!

更新在 jstack 中使用混合模式似乎提供了更多见解 - 它正在等待 pthread_cond_wait:

----------------- 2370 -----------------
0x00007f3a89115414 __pthread_cond_wait + 0xc4
0x00007f3a8833a03c _ZN13ObjectMonitor4waitElbP6Thread + 0x7dc
0x00007f3a88117fbb _ZN13instanceKlass15initialize_implE19instanceKlassHandleP6Thread + 0x36b
0x00007f3a881182ca _ZN13instanceKlass10initializeEP6Thread + 0x6a
0x00007f3a8814d3f3 _ZN18InterpreterRuntime4_newEP10JavaThreadP19constantPoolOopDesci + 0x143
0x00007f3a7d01d9ee * org.joda.time.DateTimeZone.<clinit>() bci:0 line:95 (Interpreted frame)
0x00007f3a7d0004f7 <StubRoutines>
...

最佳答案

也许它没有被卡住。它只是在循环中调用 new DateTimeZone() ,并且构造函数会执行一些计算。每次您查看此线程时,它都位于 DateTimeZone() 内部 - 但每次都是不同的 DateTimeZone()。

然后被丢弃。我身上发生过好几次了。

关于java - 如何找出线程卡住的原因?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25627312/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com