Timeout threadpool

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Timeout threadpool

jason rutherglen
Is there an implementation of a threadpool that times out?  Is there an implementation that keeps track of the time a Callable has been running?  I have already started writing my own however I was wondering if anyone else has some ideas.

Thanks,

Jason


_______________________________________________
Concurrency-interest mailing list
[hidden email]
http://altair.cs.oswego.edu/mailman/listinfo/concurrency-interest
Reply | Threaded
Open this post in threaded view
|

Re: Timeout threadpool

Bob Lee-8
Depends, how do you plan to stop your threads when they time out?

Bob

On 3/16/06, jason rutherglen <[hidden email]> wrote:

>
> Is there an implementation of a threadpool that times out?  Is there an
> implementation that keeps track of the time a Callable has been running?  I
> have already started writing my own however I was wondering if anyone else
> has some ideas.
>
> Thanks,
>
> Jason
>
>
> _______________________________________________
> Concurrency-interest mailing list
> [hidden email]
> http://altair.cs.oswego.edu/mailman/listinfo/concurrency-interest
>
>
>

_______________________________________________
Concurrency-interest mailing list
[hidden email]
http://altair.cs.oswego.edu/mailman/listinfo/concurrency-interest
Reply | Threaded
Open this post in threaded view
|

Re: Timeout threadpool

jason rutherglen
By Thread interrupt and perhaps a check inside the Callable to see if it has been cancelled.  I have (perhaps wrongly) included the Future inside the task in order to monitor whether the task is supposed to stop running at times.  Any advice?

----- Original Message ----
From: Bob Lee <[hidden email]>
To: jason rutherglen <[hidden email]>
Cc: [hidden email]
Sent: Thursday, March 16, 2006 10:41:17 AM
Subject: Re: [concurrency-interest] Timeout threadpool

Depends, how do you plan to stop your threads when they time out?

Bob

On 3/16/06, jason rutherglen <[hidden email]> wrote:

>
> Is there an implementation of a threadpool that times out?  Is there an
> implementation that keeps track of the time a Callable has been running?  I
> have already started writing my own however I was wondering if anyone else
> has some ideas.
>
> Thanks,
>
> Jason
>
>
> _______________________________________________
> Concurrency-interest mailing list
> [hidden email]
> http://altair.cs.oswego.edu/mailman/listinfo/concurrency-interest
>
>
>

_______________________________________________
Concurrency-interest mailing list
[hidden email]
http://altair.cs.oswego.edu/mailman/listinfo/concurrency-interest
Reply | Threaded
Open this post in threaded view
|

Re: Timeout threadpool

Joe Bowbeer
In reply to this post by jason rutherglen
On 3/16/06, jason rutherglen <[hidden email]> wrote:
>
> Is there an implementation of a threadpool that times out?  Is there an
> implementation that keeps track of the time a Callable has been running?  I
> have already started writing my own however I was wondering if anyone else
> has some ideas.
>

I think the c-i archives contain some discussion about this.

Two approaches are:

1. Use an auxilary ScheduledExecutor or Timer to cancel tasks
submitted to the primary executor.  The primary task could submit its
own cancellation task when it starts executing, and then cancel its
own cancellation task if it (the primary task) finishes before time
runs out.  Or, depending on how the timeout is supposed to work, the
cancellation task could be submitted at the same time the primary task
is submitted.

2. The task times its own execution using a 2nd thread.  See
TimedCallable in Doug Lea's old concurrency utils:

http://gee.cs.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/intro.html

Joe.

_______________________________________________
Concurrency-interest mailing list
[hidden email]
http://altair.cs.oswego.edu/mailman/listinfo/concurrency-interest