Hello, I am backend Web developer in Tokyo

Thread Pools in Java

Executor Framework

Main Components

  1. ExecutorService > Executor > ExecutorService
  2. ThreadPoolExecutor > Executor > ExecutorService > AbstraceExecutorService > ThreadPoolExecutor > execute() > submit() > invokeAny() > invokeAll() > shutdown() -- soft shutdown > shutdownNow() -- a waiting ExecutorSErvice will cause the JVM to kee running
  3. ScheduledThreadPoolExecutor > Executor > ExecutorService > AbstraceExecutorService > ThreadPoolExecutor > ScheduledThreadPoolExecutor > Executor > ExecutorService > ScheduledExecutorService > ScheduledThreadPoolExecutor

Fork/Join Pool Framework

This framework first ‘fork’ the given task, processing it, and then ‘join’.

Main Components

  1. ForkJoinPool > Executor > ExecutorService > AbstraceExecutorService > ForkJoinPool
  2. ForkJoinWorkerThread > Thread > ForkJoinWorkerThread Each of ForkJoinWorkerThread contains double-ended queue (deque), which stores forked tasks.
    By using this deque and Work Stealing Algorithm, Fork/Join Pool framework allows one thread to work for multiple (especially recursive) tasks.

Spring

  1. ThreadPoolTaskExecutor ``` > Executor – java.util.concurrent > TaskExecutor – org.springframework.core.task > AsyncTaskExecutor > SchedulingTaskExecutor > ThreadPoolTaskExecutor

ThreadFactory – java.util.concurrent CustomizableThreadCreator – org.springframework.scheduling … > CustomizableThreadFactory > ExecutorConfigurationSupport > ThreadPoolTaskExecutor

Executor – java.util.concurrent > TaskExecutor – org.springframework.core.task > AsyncTaskExecutor > AsyncListenableTaskExecutor > ThreadPoolTaskExecutor ```