Java线程问题

标签 java multithreading web-applications freeze

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

热点:

enter image description here

线程监视器:

enter image description here

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

有什么想法吗?

最佳答案

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

有关更多详细信息,请参阅此问题:Apache Tomcat Request Threads .

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

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

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

<小时/>

更新

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?

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

关于Java线程问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7176150/

相关文章:

java - 如何让 ContainerRequestFilter 过滤多个注释,但在 Java 中一次过滤 1 个注释?

java - Playframework 2.3.4 gzip 不工作

java - 如何枚举Spring java配置类?

linux - 在 Linux 中执行线程程序

javascript - 我应该销毁动态添加的 CodeMirror 编辑器吗?

java - servlet 规范是否保证单线程初始化和内联 attributeChanged 事件?

java - 如何统计相同的json值并将其显示在textview中?

Linux 2.6.31 调度程序和多线程作业

multithreading - 实现 token 缓存

java - 一个用于 Java 应用程序和 Web 应用程序服务器安装的安装文件?