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 https://mp.weixin.qq.com/s/baYuX8aCwQ9PP6k7TDl2Ww 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 of Executors

Use of Executors 1. Thread pool working sequence corePoolSize -> task queue -> maximumPoolSize -> deny policy 2. The factory method of the built-in thread pool 1. newFixedThreadPool JDK documentation description: Create a fixed ready-made pool that reuses a fixed number of threads. If all threads are active and there are new tasks, they will […]

spring data jpa defines interface and inherits JpaSpecificationExecutor<T> to implement dynamic query

This interface can implement jpa dynamic query based on parameters, similar to dynamic sql query based on whether parameters are passed in mybatis. layer package com.choorn.serverboot.dao; import com.choorn.serverboot.entity.Income; import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import org.springframework.data.repository.PagingAndSortingRepository; public interface IncomeDao extends PagingAndSortingRepository<Income,Long>, JpaSpecificationExecutor<Income> { } service layer implementation package com.choorn.serverboot.service.impl; import com.choorn.serverboot.dao.IncomeDao; import com.choorn.serverboot.dto.IncomeSearchDTO; import com.choorn.serverboot.entity.Income; import com.choorn.serverboot.service.IncomeService; import org.springframework.beans.factory.annotation.Autowired; […]

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>com.google.guava</groupId> <artifactId>guava</artifactId> <version>18.0</version> </dependency> View Code 2. Create an enumeration to ensure that the thread […]