首页 \ 问答 \ 应用程序需要很长时间来终止(Application takes very long to terminate)

应用程序需要很长时间来终止(Application takes very long to terminate)

我们已经编写了一个控制台应用程序(将用作服务),它启动几个工作线程来处理通过mina进入的请求。 当在特定网络端口上收到停止信号时,应用程序将离开主循环。 这是停止服务的预期方式。 这很好,但是当收到停止信号时,应用程序的进程不会立即终止(最多需要5分钟)。 我们通过日志消息验证了主函数快速并且如预期的那样,并且应用程序创建的所有线程也都被终止。 但应用程序继续运行。

在离开主函数之前仍然运行的线程是:

Signal Dispatcher (java.lang.Thread)
Finalizer (java.lang.ref.Finalizer$FinalizerThread)
Abandoned connection cleanup thread (com.mysql.jdbc.AbandonedConnectionCleanupThread)
main (java.lang.Thread)
pool-2-thread-1 (java.lang.Thread)
Reference Handler (java.lang.ref.Reference$ReferenceHandler)

我们正在使用以下java版本:

java version "1.7.0_80"
Java(TM) SE Runtime Environment (build 1.7.0_80-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode)

操作系统是Ubuntu 14.04 LTS。

我对这种行为毫无头绪,我希望能提供一些关于如何进一步调查这个问题的提示。

添加信息

我建议完成一个完整的线程转储。 四个线程正在等待:

"pool-2-thread-1" prio=10 tid=0x00007fd7fc51f000 nid=0x16200 waiting on condition [0x00007fd800318000]
   java.lang.Thread.State: TIMED_WAITING (parking)
    at sun.misc.Unsafe.park(Native Method)
    - parking to wait for  <0x00000000cceaf660> (a java.util.concurrent.SynchronousQueue$TransferStack)
    at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:226)
    at java.util.concurrent.SynchronousQueue$TransferStack.awaitFulfill(SynchronousQueue.java:460)
    at java.util.concurrent.SynchronousQueue$TransferStack.transfer(SynchronousQueue.java:359)
    at java.util.concurrent.SynchronousQueue.poll(SynchronousQueue.java:942)
    at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1068)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)

"Abandoned connection cleanup thread" daemon prio=10 tid=0x00007fd7fc23d800 nid=0x161e2 in Object.wait() [0x00007fd800cbb000]
   java.lang.Thread.State: TIMED_WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x00000000dc2af720> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:135)
    - locked <0x00000000dc2af720> (a java.lang.ref.ReferenceQueue$Lock)
    at com.mysql.jdbc.AbandonedConnectionCleanupThread.run(AbandonedConnectionCleanupThread.java:41)

"Finalizer" daemon prio=10 tid=0x00007fd7fc066000 nid=0x161d6 in Object.wait() [0x00007fd801bd6000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x00000000dc03c060> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:135)
    - locked <0x00000000dc03c060> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:151)
    at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:209)

"Reference Handler" daemon prio=10 tid=0x00007fd7fc064000 nid=0x161d5 in Object.wait() [0x00007fd801cd7000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x00000000dc03c108> (a java.lang.ref.Reference$Lock)
    at java.lang.Object.wait(Object.java:503)
    at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:133)
    - locked <0x00000000dc03c108> (a java.lang.ref.Reference$Lock)

有人可以证实,我应该调查泳池2线程1吗? 我不确定如何解释结果。

解决方案最后,对acceptor.dispose(MINA)的调用做了诀窍...


We have writen a console application (will be used as service) that starts several worker threads for handling requests coming in via mina. The application leaves the main loop when a stop signal is received on a specific network port. This is the intended way of stoping the service. That works quite ok, but when the stop signal is received the process of the application does not terminate immediatly (takes up to 5 minutes). We verified via log messages that the main function is left quickly and as expected and all threads created by the application are also terminated. But the application keeps on running.

The threads still running before leaving the main function are:

Signal Dispatcher (java.lang.Thread)
Finalizer (java.lang.ref.Finalizer$FinalizerThread)
Abandoned connection cleanup thread (com.mysql.jdbc.AbandonedConnectionCleanupThread)
main (java.lang.Thread)
pool-2-thread-1 (java.lang.Thread)
Reference Handler (java.lang.ref.Reference$ReferenceHandler)

We are currently using the following java version:

java version "1.7.0_80"
Java(TM) SE Runtime Environment (build 1.7.0_80-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode)

The operation system is ubuntu 14.04 LTS.

I have no clue about this behaviour and i hope for some hints on how to investigate that problem further.

Addtional Information

I have produced a Full thread dump as suggested. Four threads are waiting:

"pool-2-thread-1" prio=10 tid=0x00007fd7fc51f000 nid=0x16200 waiting on condition [0x00007fd800318000]
   java.lang.Thread.State: TIMED_WAITING (parking)
    at sun.misc.Unsafe.park(Native Method)
    - parking to wait for  <0x00000000cceaf660> (a java.util.concurrent.SynchronousQueue$TransferStack)
    at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:226)
    at java.util.concurrent.SynchronousQueue$TransferStack.awaitFulfill(SynchronousQueue.java:460)
    at java.util.concurrent.SynchronousQueue$TransferStack.transfer(SynchronousQueue.java:359)
    at java.util.concurrent.SynchronousQueue.poll(SynchronousQueue.java:942)
    at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1068)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)

"Abandoned connection cleanup thread" daemon prio=10 tid=0x00007fd7fc23d800 nid=0x161e2 in Object.wait() [0x00007fd800cbb000]
   java.lang.Thread.State: TIMED_WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x00000000dc2af720> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:135)
    - locked <0x00000000dc2af720> (a java.lang.ref.ReferenceQueue$Lock)
    at com.mysql.jdbc.AbandonedConnectionCleanupThread.run(AbandonedConnectionCleanupThread.java:41)

"Finalizer" daemon prio=10 tid=0x00007fd7fc066000 nid=0x161d6 in Object.wait() [0x00007fd801bd6000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x00000000dc03c060> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:135)
    - locked <0x00000000dc03c060> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:151)
    at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:209)

"Reference Handler" daemon prio=10 tid=0x00007fd7fc064000 nid=0x161d5 in Object.wait() [0x00007fd801cd7000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x00000000dc03c108> (a java.lang.ref.Reference$Lock)
    at java.lang.Object.wait(Object.java:503)
    at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:133)
    - locked <0x00000000dc03c108> (a java.lang.ref.Reference$Lock)

Can someone confirm, that I should investigate towards pool-2-thread-1? I'm unsure how to interpret the result.

Solution In the end a call to acceptor.dispose (MINA) did the trick...


原文:https://stackoverflow.com/questions/30120453
更新时间:2023-06-17 08:06

最满意答案

我试图复制这个问题没有成功。

这是我的ViewScoped bean的属性:

private String str1 = "a";

private String str2 = "b";

private String update = ":f:t";

private Integer index = 0;

以下是观点:

<h:form id="f">
    <p:tabView id="t" widgetVar="tVar" activeIndex="#{viewMBean.index}" >
        <p:tab id="a" title="A" >
            #{viewMBean.str1}
        </p:tab>
        <p:tab id="b" title="B">
            #{viewMBean.str2}
        </p:tab>
    </p:tabView>
</h:form>

<p:dialog id="d" widgetVar="dVar">
    <h:form>
        <p:inputText value="#{viewMBean.str1}" />
        <br />
        <p:inputText value="#{viewMBean.str2}" />
        <br />
        <p:inputText value="#{viewMBean.update}" />
        <br />
        <p:inputText value="#{viewMBean.index}" />
        <br />
        <p:commandButton value="Submit" update="#{viewMBean.update}" oncomplete="dVar.hide();" />
    </h:form>
</p:dialog>

我相信问题出在代码中的其他地方。


I've tried to replicate the problem with no success.

Here is a the attribute from my ViewScoped bean:

private String str1 = "a";

private String str2 = "b";

private String update = ":f:t";

private Integer index = 0;

And here is the view:

<h:form id="f">
    <p:tabView id="t" widgetVar="tVar" activeIndex="#{viewMBean.index}" >
        <p:tab id="a" title="A" >
            #{viewMBean.str1}
        </p:tab>
        <p:tab id="b" title="B">
            #{viewMBean.str2}
        </p:tab>
    </p:tabView>
</h:form>

<p:dialog id="d" widgetVar="dVar">
    <h:form>
        <p:inputText value="#{viewMBean.str1}" />
        <br />
        <p:inputText value="#{viewMBean.str2}" />
        <br />
        <p:inputText value="#{viewMBean.update}" />
        <br />
        <p:inputText value="#{viewMBean.index}" />
        <br />
        <p:commandButton value="Submit" update="#{viewMBean.update}" oncomplete="dVar.hide();" />
    </h:form>
</p:dialog>

I believe the problem is somewhere else in your code.

相关问答

更多
  • 这有点hacky,但我把我在.ready()上做的所有事情都放到一个名为loadDataAndPopulateToken()的函数中,然后除了在.ready()上运行该函数之外,我还将它绑定到窗口聚焦: $(document).ready(function(){ // initial token load (doesn't work if in background tab) loadDataAndPopulateToken(); // reload the token data whenev ...
  • 实际上,这个问题与其他两个问题的结合是重复的。 无论如何,我会在这里回答它以强调相关性(需要!),以便始终尝试用更通用,更易于管理的部分来分解您的问题,以便找到答案。 在这种情况下,“两个”问题是: 我可以通过例如javascript从客户端停止/启动民意调查吗? 我可以检测浏览器选项卡是否关注。 两者都比搜索引擎更容易通过搜索引擎解决。 我将谷歌搜索放在上面的“列表项”后面。 这导致 如何从javascript正确启动/停止PrimeFaces Ajax Poll 有没有办法检测浏览器窗口当前是否处于活动 ...
  • 您可以使用tabView中的activeIndex属性: 从Primeface用户指南 : activeIndex是一个整数,默认值为0.活动选项卡的索引。 You could use activeIndex attribut from tabView : From Primeface User Guide: acti ...
  • 更新数据结构后,需要调用tableView.reloadData 。 这必须在主线程中完成,因此: let task = NSURLSession.sharedSession().dataTaskWithURL(url!) {(data, response, error) in println(NSString(data: data, encoding: NSUTF8StringEncoding)) var error: NSError? let jsonData: NSDa ...
  • 相关文章

    更多
  • 干干净净终结进程[转] Terminate process cleanly [reprint]
  • Mod_python: The Long Story
  • Guava LongMath类-long基础类型的Math实用方法
  • Guava Longs类-long的实用工具类
  • java Long型的比较
  • -bash: /bin/mv: Argument list too long的解决方案
  • Quitting an application - is that frowned upon?
  • Android 使用隐藏API 开发应用程序
  • Hibernate在Web应用程序中使用示例
  • Chapter 9 - Securing Your Application -- Professional ASP.NET MVC 1.0
  • 最新问答

    更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。