| Author |
How to timeout a task in ThreadPoolExecutor
|
Thiyagarajan Ramasamy
Greenhorn
Joined: Jan 15, 2010
Posts: 1
|
|
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 ThreadPoolExecutor, 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.
|
 |
Rok Ć telcer
Ranch Hand
Joined: Nov 03, 2009
Posts: 101
|
|
Hi,
Check the following api: FutureTask#get(int, TimeUnit).
Hope it helps.
Regards,
Rok
|
SCJP, SCWCD
|
 |
abhay bansal
Greenhorn
Joined: Nov 26, 2009
Posts: 8
|
|
Hi,
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.
Thanks
Abhay
|
 |
 |
|
|
subject: How to timeout a task in ThreadPoolExecutor
|
|
|