开发者

how do I set time limits for individual threads in a thread pool?

开发者 https://www.devze.com 2023-02-13 07:26 出处:网络
how do I set time limits for individual threads in a thread pool..? The parent thread need not wait until eve开发者_如何学Gory thread finishes and returns back. Instead it should fetch the next job(r

how do I set time limits for individual threads in a thread pool..? The parent thread need not wait until eve开发者_如何学Gory thread finishes and returns back. Instead it should fetch the next job(runnable/callable) and submit to the thread pool...


More context would be useful.

You might try using ExecutorCompletionService:

http://download.oracle.com/javase/1.5.0/docs/api/java/util/concurrent/ExecutorCompletionService.html


You can add a task to the same pool, or another one which will cancel the first task after a given amount of time. If it has completed this does nothing.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号