java - SingleThreadExecutor and ThreadFactory -


am right every time, when performing several submit operations:

executorservice executor = executors.newsinglethreadexecutor(             new mythreadfactory("someexecutor")); executor.submit(...); executor.submit(...); executor.submit(...); 

method java.util.concurrent.threadfactory#newthread executes once? or executes every time , creates new thread per submit call?

it reuses same thread everytime.

that beauty of thread pools: avoid cost of creating new thread reducing per-task invocation overhead.

you can read more how threads created in threadpoolexecutor documentation.


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -