Quote
void execute(Runnable command)
Executes the given command at some time in the future. The command may execute in a new thread, in a pooled thread, or in the calling thread, at the discretion of the Executor implementation.
My question is in regards to the bold green and red text above. What does it mean, "at the discretion of the Executor implementation?"
Basically, I want to ensure that my Executor does not execute my Runnable in the calling thread. The reason being is that the calling thread should not be tied up with lengthy tasks, as it needs to be free in the background to read and write data on a Socket. That's the whole point behind my using an Executor, so I can dump lengthy tasks into it whenever I want and forget about them (from the calling thread's point of view, that is). How can I be sure that the Executor won't use the calling thread?
I'm using a cached thread pool created by Executors.newCachedThreadPool() if that's relevant.


Sign In
Create Account


Back to top










