Sobes.tech
Middle

What happens if the thread pool queue is full but a new task arrives?

sobes.tech AI

Answer from AI

A rejected execution handler (RejectedExecutionHandler) will be applied. Standard handlers include:

  • AbortPolicy: Throws a RejectedExecutionException.
  • DiscardPolicy: Silently discards the task.
  • DiscardOldestPolicy: Discards the oldest task in the queue and attempts to execute the new one.
  • CallerRunsPolicy: Executes the task in the calling thread.

The specific behavior depends on which handler was configured when creating the thread pool.

What happens if the thread pool queue is full but a… - sobes.tech