Java后台任务 [英] java background task

查看:112
本文介绍了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.

推荐答案

您应该使用线程池,

http://java.sun.com/docs /books/tutorial/essential/concurrency/pools.html

这篇关于Java后台任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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