Java后台任务

编程入门 行业动态 更新时间:2024-10-21 15:48:51
本文介绍了Java后台任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想知道哪种方法是在Java中实现某种后台任务的最有效方法(我想那是某种非阻塞线程).更准确地说-我有一些Java代码,然后在某个时候我需要执行长时间运行的操作.我想做的是在后台执行该操作,以便程序的其余部分可以继续执行,并且当该任务完成时,只需更新一些特定的对象即可.然后,其他组件将检测到此更改.

I was wondering which would be the most efficient approach to implement some kind of background task in java (I guess that would be some kind of nonblocking Threads). To be more precise - I have some java code and then at some point I need to execute a long running operation. What I would like to do is to execute that operation in the background so that the rest of the program can continue executing and when that task is completed just update some specific object which. This change would be then detected by other components.

推荐答案

您应该使用线程池,

java.sun/docs /books/tutorial/essential/concurrency/pools.html

更多推荐

Java后台任务

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

发布评论

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

>www.elefans.com

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