views:

22

answers:

0

Hi, I'm trying to understand if the ScheduledThreadPoolExecutor class "ties" a thread to a task when it is only scheduled or only during its run?(of course that when it's finished there is no relation).
You can see in the link supplied that schedule(..) calls delayedExecute(...) which is ok but then delayedExecute calls prestartCoreThread().

Why? and does this mean that a thread is tied? Or is it merely an optimization feature to try to verify that there will be a thread available to service the task (if not allready initialized all the pool)?
In the explanation there it says that prestartCoreThread method:

"...This overrides the default policy of starting core threads only when new tasks are executed..."

So I'm not sure what actually takes place. I think I'd like to use the ScheduledThreadPoolExecutor with the default policy of starting core threads only when a new task is executed, but there could probably be a reason no to do so which I'm overlooking.