Java线程问题

发布于 2024-12-01 10:42:25 字数 386 浏览 5 评论 0原文

上次更新后(我在其中找不到任何犯罪行为),我的应用程序在工作 1-2 小时后开始挂起。我分析了我的应用程序:一切正常,但一段时间后我看到了:

热点:

在此处输入图像描述

线程监视器:

在此处输入图像描述

它可能是什么?我不知道,因为 Tomcat 日志不包含错误,而且我看不到操作堆栈(只有直接 JVM 调用 - 参见图片)。此外,我在这个 Tomcat 上还有另一个应用程序,它(另一个应用程序)仍然可以完美运行。

有什么想法吗?

After last update (I can't find nothing criminal in it) my appication starts hang on after 1-2 hours of work. I profiled my app: everything was ok, but after some time I see this:

Hot spots:

enter image description here

Thread monitor:

enter image description here

What it can be? I have no idea, because Tomcat log doesn't contain errors and I can't see stack of operation (only direct JVM call - see at picture). Moreover, I have another application at this Tomcat, and it (another application) still perfectly works.

Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

静谧 2024-12-08 10:42:25

这是您的 HTTP 连接器线程池,有大量等待线程是完全正常的。

有关更多详细信息,请参阅此问题:Apache Tomcat 请求线程

您的表不是很清楚,但看起来消耗了应用程序 88% 的执行时间 - 它们没有使用 88% 的系统 CPU 时间 - 毕竟,它们正在等待线程。

使用库存设置,实际上有 25 个等待线程(请参阅链接的问题)。 2 小时内 404 秒 / 25 秒似乎并不过分。这相当于每小时大约 8 秒的 CPU 时间。

更有可能的是,您只是在新添加的同步功能中遇到了并发问题 - 您可能应该发布一个特定于该问题的问题 - 如果其他应用程序继续运行,那么您的问题看起来并不在于 Tomcat 或线程池。


更新

BLOCKED 状态和 WAITING / TIMED_WAITING 之间的区别
州?

当一个线程调用Object.wait方法时,它会释放所有已获取的
监视并被放入 WAITING (或 TIMED_WAITING 如果我们调用
等待方法的超时版本)状态。现在当线程是
通过对同一对象调用notify()或notifyAll()来通知
然后线程的等待状态结束,线程启动
试图重新获得它在
等待呼叫的时间。同时可能有多个线程尝试
重新获得(或者可能是第一次获得)他们的显示器。如果超过
然后一个线程尝试获取特定对象的监视器
只有一个线程(由 JVM 调度程序选择)被授予监视器
并且所有其他线程都被置于 BLOCKED 状态。看出区别了吗?

来源:http://geekexplains.blogspot。 com/2008/07/threadstate-in-java-blocked-vs-waiting.html

That's your HTTP connector thread pool, it's perfectly normal to have a number of waiting threads.

See this question for more details: Apache Tomcat Request Threads.

Your table isn't very clear, but it looks like that consumed 88% of the execution of your app - they're not using 88% of the system's CPU time - after all, they're waiting threads.

Using stock settings, there are actually 25 waiting threads (see the linked question). 404 seconds / 25 over 2 hours doesn't seem excessive. That's around 8 seconds of CPU time per hour.

It's more likely that you just have a concurrency problem with your newly added synchronized functionality - you should probably post a question specific to that - it doesn't look like your issue is with Tomcat or it's thread pool if the other app continues to function.


Update

Difference between BLOCKED state and WAITING / TIMED_WAITING
states?

When a thread calls Object.wait method, it releases all the acquired
monitors and is put into WAITING (or TIMED_WAITING if we call the
timeout versions of the wait method) state. Now when the thread is
notified either by notify() or by notifyAll() call on the same object
then the waiting state of the thread ends and the thread starts
attempting to regain all the monitors which it had acquired at the
time of wait call. At one time there may be several threads trying to
regain (or maybe gain for the first time) their monitors. If more than
one threads attempt to acquire the monitor of a particular object then
only one thread (selected by the JVM scheduler) is granted the monitor
and all other threads are put into BLOCKED state. Got the difference?

Source: http://geekexplains.blogspot.com/2008/07/threadstate-in-java-blocked-vs-waiting.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文