Websphere尊重Daemon线程吗? [英] Does Websphere respect Daemon threads?

查看:315
本文介绍了Websphere尊重Daemon线程吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序创建了一个加载Daemon线程,我想让每个人关闭时,应用程序关闭。

I've got an app that creates a load of Daemon threads, I'd like each one to shut down when the app is shut down.

有人担心Websphere 7可能不会关闭它们。

I'm a little worried thought that Websphere 7 might not be shutting them all down.

有没有人知道Websphere 7会如何处理Daemons线程? (我知道它应该做)

Does anyone know if Websphere 7 treats Daemons threads differently? (I know it should do)

注意:
我知道什么不应手动创建线程,我应该使用WebSphere WorkManager或其他东西,这个应用程序必须在Tomcat和WebSphere中运行。

Note: I know what shouldn't create threads manually, and that I should probably use WebSphere WorkManager or something, but this app has to run in Tomcat and WebSphere.

我知道我应该将所有线程绑定到一些上下文/关闭机制,正在进行中。

I know that I should tie in all threads to some context/shutdown mechanism, this is in progress.

推荐答案

每个WAS服务器运行单个JVM,守护线程绑定到JVM的生命周期,而不是应用程序的生命周期。因此,您不应该期望在应用程序停止时关闭任何后台进程线程。

Each WAS server runs a single JVM, and daemon threads are tied to the JVM's lifecycle, not the app's lifecycle. Therefore, you should not expect any daemon threads to be shut down when your app stops.

正如您已经指出的,您不应手动创建线程; Java EE规范禁止这一点,并且Java EE容器中的行为不同于您已经发现的独立Java应用程序。不幸的是,目前没有用于WorkManager等价物的Java EE标准;但是, JSR-236 (Java EE的并发实用程序)可能会恢复为可包含在 Java EE 7 中的候选人。

As you've already indicated, you should not create threads manually; the Java EE specs forbid this and the behavior in a Java EE container is different than a standalone Java application as you've already found. Unfortunately, there is currently no Java EE standard for a WorkManager equivalent; however, JSR-236 (Concurrency Utilities for Java EE) may be back as a candidate for inclusion in Java EE 7.

同时,在WAS上,您可以使用异步bean WorkManager )。我们已成功使用此方法将线程绑定到应用程序生命周期。

In the meantime, on WAS, you can use the asynchronous beans (WorkManager). We have successfully used this method to tie threads to the application lifecycle.

但是,由于您需要在另一个容器(Tomcat)中运行,考虑在应用程序中处理并发的选项:

However, since you need to run in another container as well (Tomcat), there may be some other options to consider handling concurrency in your applications:

  • CommonJ WorkManager
  • Servlet 3.0 Asynchronous Servlets
  • ServletContextListener to hook into the web app lifecycle

处理并发性的其他一些潜在选项包括以下内容,但这些选项需要EJB,它们在Tomcat中可能不可用:

Some other potential options for handling concurrency include the following, but these require EJBs, which may not be available in Tomcat:

  • EJB 3.0 Timer Service
  • EJB 3.1 Asynchronous Beans

以下是Java EE中并发主题的几个相关主题:

Here are a few related threads on the topic of concurrency in Java EE:

  • Replacing Websphere's WorkManager in JBoss?
  • Getting thread from Container?

这篇关于Websphere尊重Daemon线程吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆