<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Thread-Pool on Kevin wang's blog</title><link>https://kevinwang930.github.io/tags/thread-pool/</link><description>Recent content in Thread-Pool on Kevin wang's blog</description><generator>Hugo</generator><language>en-US</language><lastBuildDate>Sun, 05 Jul 2026 00:00:00 +0800</lastBuildDate><atom:link href="https://kevinwang930.github.io/tags/thread-pool/index.xml" rel="self" type="application/rss+xml"/><item><title>java concurrency - thread pool and BlockingQueue</title><link>https://kevinwang930.github.io/post/java/concurrency/thread-pool-blocking-queue/</link><pubDate>Sun, 05 Jul 2026 00:00:00 +0800</pubDate><guid>https://kevinwang930.github.io/post/java/concurrency/thread-pool-blocking-queue/</guid><description>&lt;p&gt;A Java thread pool separates &lt;strong&gt;task submission&lt;/strong&gt; from &lt;strong&gt;task execution&lt;/strong&gt;. Submitting threads hand &lt;code&gt;Runnable&lt;/code&gt; objects to an &lt;code&gt;ExecutorService&lt;/code&gt;; a set of worker threads removes those tasks and runs them. In &lt;code&gt;ThreadPoolExecutor&lt;/code&gt; and &lt;code&gt;ScheduledThreadPoolExecutor&lt;/code&gt; the hand-off point between the two sides is a &lt;code&gt;java.util.concurrent.BlockingQueue&amp;lt;Runnable&amp;gt;&lt;/code&gt;. The queue therefore decides how tasks are buffered, ordered and throttled, and the pool decides how many threads consume them.&lt;/p&gt;&#10;&lt;p&gt;This article first enumerates the thread pool and blocking queue types of the JDK. Part 1 then examines the OpenJDK &lt;code&gt;BlockingQueue&lt;/code&gt; implementations: the dual-condition bounded buffer, the two-lock design of &lt;code&gt;LinkedBlockingQueue&lt;/code&gt;, the heap-backed &lt;code&gt;PriorityBlockingQueue&lt;/code&gt;, the zero-capacity rendezvous of &lt;code&gt;SynchronousQueue&lt;/code&gt;, and the timed waiting protocol of &lt;code&gt;DelayQueue&lt;/code&gt;. Part 2 examines the thread pools built on them: the control state, admission, worker loop, rejection and shutdown of &lt;code&gt;ThreadPoolExecutor&lt;/code&gt;, the &lt;code&gt;Executors&lt;/code&gt; factories, and the scheduling of &lt;code&gt;ScheduledThreadPoolExecutor&lt;/code&gt;.&lt;/p&gt;</description></item></channel></rss>