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

c - Calling a function within a loop -

vb.net - Unbound DataGridView add row with checkbox error -

How i fill combobox items in Radgridview manually using in vb.net -