简体   繁体   English

Tomcat会启动线程,但无法停止。 发生了什么?

[英]Thread starts and fails to stops with Tomcat. What's happening?

i have a java multi-threaded program that is running. 我有一个正在运行的Java多线程程序。 i am running it on a tomcat server. 我在雄猫服务器上运行它。 when the threads are still running, some executing tasks, some still waiting for some thing to return and all kinds of things, assume i stop the server all of a sudden in this scenario.. when i do i get a warning on the tomcat terminal saying a thread named x is still running and the server is being stopped so this might lead to a memory leakage. 当线程仍在运行时,一些正在执行的任务,一些仍在等待某些事物返回以及各种各样的事物,假设在这种情况下我突然停止了服务器。.当我这样做时,tomcat终端上出现警告表示名为x的线程仍在运行,并且服务器正在停止,因此这可能导致内存泄漏。 what is the OS actually trying to tell me here? 操作系统实际上想在这里告诉我什么? can someone help me understand this?? 有人可以帮我理解吗? i am running this program on my system several times and i have stopped the server abruptly 3 times and i have seen this message when ever i do that. 我在系统上多次运行了该程序,并且突然停止了服务器3次,并且每次执行此操作时都看到此消息。 have i runined my server? 我已经运行服务器了吗? (i mean my system). (我的意思是我的系统)。 did i do something very dangerous???? 我做了非常危险的事情吗???

please help. 请帮忙。

Thanks in advance! 提前致谢!

when i do i get a warning on the tomcat terminal saying a thread named x is still running and the server is being stopped so this might lead to a memory leakage. 当我这样做时,我在tomcat终端上收到一条警告,说一个名为x的线程仍在运行,并且服务器正在停止,因此这可能导致内存泄漏。 what is the OS actually trying to tell me here? 操作系统实际上想在这里告诉我什么?

Tomcat (not the OS) is surmising from this extra thread that some part of your code forked a thread that may not be properly cleaning itself up. Tomcat(不是OS)从这个额外的线程中推测出,您的代码的某些部分分叉了一个线程,该线程可能无法正确清理自身。 It is thinking that maybe this thread is forked more than once and if your process runs for a long time, it could fill up usable memory which would cause the JVM to lock up or at least get very slow. 我们认为该线程可能被分叉了多次,并且如果您的进程运行了很长时间,它可能会填满可用的内存,这将导致JVM锁定或变得非常缓慢。

have i ruined my server? 我毁了服务器吗? (i mean my system). (我的意思是我的系统)。 did i do something very dangerous???? 我做了非常危险的事情吗???

No, no. 不,不。 This is about the tomcat process itself. 这是关于tomcat进程本身。 It is worried that this memory leak may stop its ability to do its job as software -- nothing more. 令人担心的是,这种内存泄漏可能会停止其作为软件的工作能力,仅此而已。 Unless you see more than one thread or until you see memory problems with your server (use jconsole for this) then I would only take it as a warning and a caution. 除非您看到多个线程,或者直到您看到服务器的内存问题(为此使用jconsole),否则我只会将其作为警告和注意事项。

It sounds like your web server is forking processes which are not terminated when you stop the server. 听起来您的Web服务器正在派生进程,但在停止服务器时该进程不会终止。 Those could lead to a memory leak because they represent processes that will never die unless you reboot or manually terminate them with the kill command. 这些可能会导致内存泄漏,因为它们表示除非重新启动或使用kill命令手动终止它们,否则它们将永远不会消失。

I doubt that you will permanently damage your system, unless those orphaned processes are doing something bad, but that would be unrelated to you stopping the server. 我怀疑您是否会永久损坏系统,除非这些孤立的进程做错了什么,但这与停止服务器无关。 You should probably do something like ps aux | grep tomcat 您可能应该做类似ps aux | grep tomcat事情ps aux | grep tomcat ps aux | grep tomcat to find the leftover processes and do the following ps aux | grep tomcat查找剩余的进程并执行以下操作

  1. Kill them so they don't take up more system resoures. 杀死它们,这样它们就不会占用更多的系统资源。
  2. Figure out why they are persisting when the server is stopped. 找出为什么它们在服务器停止时仍然存在。 This sounds like a misbehaving server. 这听起来像是服务器行为异常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM