Java EE中的长生存线程(Long living threads in Java EE)

编程入门 行业动态 更新时间:2024-10-28 19:32:15
Java EE中的长生存线程(Long living threads in Java EE)

我需要为这些特性编写一个Java系统。

- 当系统启动时,需要创建一些需要在系统运行时永久生存的对象。 同样在对象的构造函数中,将创建新线程,并且在系统运行时这些线程也需要存活。

- 系统需要公开一个将使用启动时创建的对象的Web服务。

为了给出我需要做什么的背景,我需要编写一个应用程序,当它启动时,它会创建一些负责执行轮询任务的对象。 另外我需要一个使用这些对象来处理请求的Web服务。

我如何在Java中实现这些? 我正在考虑使用Java EE来实现Web服务,也是因为我打算实现一个使用Web服务的Web界面。 但是我所拥有的大问题是,如何在Java EE中实现自应用程序启动后永远存在的线程?

I need to code a Java system with these characteristics.

-When the system starts up, it needs to create some objects that need to live forever while the system is running. Also on the constructor of the objects, new threads will be created and these threads will also need to live while the system is running.

-The system needs to expose a web service that will use the object that were created on startup.

To give a context of what do I need to do, I need to code an app that when it starts up it creates some objects that are in charge of doing a polling task. Also I need a web service that uses these objects to process their requests.

How do I implement these in Java? I was thinking of using Java EE to implement the web services and also because I'm planning to implement a web interface that consumes the web services. But the BIG QUESTION that I have is, how do I implement in Java EE the threads that live forever since the application starts?

最满意答案

如果您采用Java EE方式,则应考虑EJB定时服务 。

If you are going the Java EE way, you should consider the EJB Timer Service.

更多推荐

本文发布于:2023-07-16 02:45:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1122701.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:线程   EE   Java   threads   living

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!