Doubt regarding ThreadPoolExecutor
posted 9 years ago
First, there are many different ExecutorService implementations, and there is no general guarantee that would apply to all of them. Since it's an interface, I could make my own implementation of it that may behave differently than those that Sun makes. Second, as soon as we're talking about threads, it's impossible to guarantee that anything will happen immediately. Even if the thread is started immediately, as long as there are other threads running, we can't guarantee how soon it will be before the new thread starts. Third, in all likelihood yes, the new Runnable will be assigned a pooled thread right away, and will start executing as quickly as any thread might be expected to execute. Which is generally pretty fast unless you have too many threads. I don't really see a way to answer this more specifically. You can always run some tests for yourself, logging times using System.currentTimeMillis() to see how much time elapses between calling execute() and calling run().