Thoughts on java thread pool ThreadPoolExecutor monitoring and dynamic parameter adjustment

Table of Contents For thread pool parameters For task submission strategy Respond quickly to user requests The default strategy of java ThreadPoolExecutor is as follows The tomcat ThreadPoolExecutor strategy is as follows Process batch tasks quickly Thread pool monitoring Dynamic adjustment of thread pool parameters Java thread pool implementation principle and its practice in […]

java thread pool ThreadPoolExecutor and ThreadPoolTaskExecutor

Foreword 1. What are the benefits of using a thread pool Reduce resource consumption. Reduce the cost of thread creation and destruction by reusing created threads. Improve responsiveness. When a task arrives, the task can be executed immediately without waiting for the thread to be created. Improve thread manageability. Threads are scarce resources. If they […]

Concurrent programming – ScheduledThreadPoolExecutor

Article directory Introduction to ScheduledThreadPoolExecutor ScheduledFutureTask Four ways to perform tasks execute method schedule method Analysis of scheduleAtFixedRate and scheduleWithFixedDelay Introduction to ScheduledThreadPoolExecutor ScheduledThreadPoolExecutor is a subclass of ThreadPoolExecutor, which implements the function of delayed execution of tasks and periodic execution of tasks based on the thread pool. The first thing Java provided was the […]

Use ThreadPoolExecutor to create a thread pool and complete parallel operations

Many extremely inefficient operations in many places in daily work can often be changed from serial to parallel, and the execution efficiency is often improved several times. Without further ado, let’s start with the code. 1. Guava coordinates used <dependency> <groupId></groupId> <artifactId>guava</artifactId> <version>18.0</version> </dependency> View Code 2. Create an enumeration to ensure that the thread […]


The official API explains the benefits of thread pools: (1) Reduce the performance overhead of creating and destroying each thread by reusing threads in the thread pool. (2) Perform some maintenance and management of threads, such as scheduled start, periodic execution, concurrency control, etc. 1. Executor Executor is an interface, and everything related to the […]

Explore the memory leak risks and prevention strategies in ThreadLocal and ThreadPoolExecutor

Explore the memory leak risks and prevention strategies in ThreadLocal and ThreadPoolExecutor This article will discuss possible memory leak issues in ThreadLocal and ThreadPoolExecutor, and propose corresponding prevention strategies. Memory leak problem of ThreadPoolExecutor ThreadPoolExecutor is a thread pool class that can manage and reuse threads, thereby improving program performance and stability. However, ThreadPoolExecutor can […]

Java thread pool ThreadPoolExecutor application (Spring Boot microservice)

Records: 475 Scenario: Using Java thread pool ThreadPoolExecutor in Spring Boot microservices. Implement the Runnable interface to submit thread tasks to the thread pool. Version: JDK 1.8, Spring Boot 2.6.3. 1. Use annotations to configure the thread pool ThreadPoolExecutor (1)Explanation ThreadPoolExecutor, full name: java.util.concurrent.ThreadPoolExecutor. Use the @Bean(“threadPoolExecutorHz”) annotation to inject the thread pool into the […]