If I configure ThreadPoolExecutorFactoryBean with maxPoolSize=1 - so executor always has 1 thread - if I run 2 or 开发者_如何学Pythonmore threads - spring create some queue or next invocation will wait previous? Thanks.
If the maxPoolSize is 1, then only one thread will run at the same time, so only one task will be executed at the same time. However, the ThreadPoolExecutor has a queue, so any tasks that are not executed immediately will be done asynchronously when a thread becomes available.
So when you have an ThreadPoolExecutor with maxPoolSize 1, the following code will return immediately
executor.execute(runnable1);
executor.execute(runnable2);
and runnable1 will be executed in the thread first, once that's finished, runnable2 will be executed.
精彩评论