File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Threads and Synchronization
How to timeout a task in ThreadPoolExecutor
Joined: Jan 15, 2010
Jan 15, 2010 06:39:02
Multi Threading Gurus,
I have to execute a set of runnable tasks in parallel and each of the task shouldn't execute more than 2 mins.
I was thinking of using
, but there is seems to be no way to interrupt / configure timeout for a task. I can only configure the timeout for the pool.
Is there any way to achieve this?
Thanks in advance.
Joined: Nov 03, 2009
Jan 16, 2010 02:33:37
Check the following api:
Hope it helps.
Joined: Nov 26, 2009
Jan 19, 2010 02:39:40
Correct me if I am wrong. A task when submitted to an executor and when the worker thread picks up the task even the executor has no control over the task then. It is al in the hands of the worker thread.
I agree. Here's the link:
- if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
subject: How to timeout a task in ThreadPoolExecutor
cancel tasks after a certain time
running a fixed number of threads all the time
Better than ThreadPoolExecutor
execute vs submit ( ThreadPoolExecutor)
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2013