[concurrency-interest] missed deadlines.
taras.tielkes at gmail.com
Thu Jul 6 14:57:14 EDT 2006
Peter Veentjer wrote:
> I have a question regarding missed deadlines and java.util.Timer and
> I'm wondering why there is no functionality for dealing with missed
> deadlines. Within a Timer you have one thread, if a job takes a long
> time, the other tasks are 'queued' untill the long-job has finished.
> When that job finishes, all other queued-jobs are run and I think this
> could lead to some serious issues. I can image you want to have some
> control like:
> -execute it
> -drop it
> -do something else like sending a message.
> The same goes for the ScheduledThreadPoolExecutor. If a job takes a
> long time and a different job needs to be scheduled, a free thread is
> used (if one is available). If no free thread is available, you get
> the same problems as with the Timer.
You can do (part of) this using get(long,TimeUnit) on a Future. This
shifts this responsibility to the caller (I think that's good).
> Another think I'm wondering about is the fixed size of the threadpool
> of the scheduledthreadpoolexecutor. I can image it would be usefull
> that a threadpool increases if there are no available threads to
> execute a scheduled task and if those 'extra' threads aren't used for
> some time, they could be discarded. Am I missing something?
I usually use the "execute in caller thread" policy. If a pool if
totally stuffed if won't help adding more threads (in the case of cpu
More information about the Concurrency-interest