Tag

ExecutorService

0 views collected around this technical thread.

FunTester
FunTester
Jun 17, 2025 · Backend Development

How to Test Java ExecutorService Without Thread.sleep(): Reliable Strategies

This article explains why using Thread.sleep() in Java ExecutorService unit tests is unreliable and inefficient, and introduces three robust alternatives—Future.get(), CountDownLatch, and shutdown/awaitTermination—to achieve stable and performant testing of asynchronous code.

ConcurrencyCountDownLatchExecutorService
0 likes · 13 min read
How to Test Java ExecutorService Without Thread.sleep(): Reliable Strategies
Cognitive Technology Team
Cognitive Technology Team
May 1, 2025 · Backend Development

10 Tips and Tricks for Using ExecutorService in Java

This article presents ten practical tips for Java developers on naming thread‑pool threads, dynamically changing thread names, safely shutting down executors, handling interruptions, bounding queue sizes, proper exception handling, monitoring wait times, preserving client stack traces, preferring CompletableFuture, and using SynchronousQueue with ThreadPoolExecutor.

Best PracticesConcurrencyExecutorService
0 likes · 15 min read
10 Tips and Tricks for Using ExecutorService in Java
Java Captain
Java Captain
Apr 27, 2025 · Backend Development

Understanding Java Executors Thread Pools: newCachedThreadPool, newScheduledThreadPool, newSingleThreadExecutor, newWorkStealingPool, and newFixedThreadPool

This article explains the five main thread‑pool types provided by Java's Executors class, detailing their constructors, underlying queue implementations, and default thread‑count behaviors, and notes why the default pools may not suit everyday development needs.

ConcurrencyExecutorServiceExecutors
0 likes · 4 min read
Understanding Java Executors Thread Pools: newCachedThreadPool, newScheduledThreadPool, newSingleThreadExecutor, newWorkStealingPool, and newFixedThreadPool
Code Ape Tech Column
Code Ape Tech Column
Mar 19, 2025 · Backend Development

ExecutorService vs CompletionService: In‑Depth Comparison and Practical Usage in Java

This article explains the differences between ExecutorService and CompletionService, demonstrates how to replace a simple Future‑based approach with CompletionService for faster result retrieval, analyzes the underlying source code, and outlines typical use‑cases such as load‑balancing and early‑return patterns in concurrent Java applications.

AsyncCompletionServiceExecutorService
0 likes · 12 min read
ExecutorService vs CompletionService: In‑Depth Comparison and Practical Usage in Java
FunTester
FunTester
Feb 6, 2025 · Backend Development

Choosing and Customizing Thread Pools for Java Performance Testing

This article explains how to select and customize a Java thread pool for performance testing, covering parameter considerations, modifications to the standard fixed thread pool, custom thread factories, work queue choices, and provides complete example code for both fixed and TPS models.

ConcurrencyExecutorServiceJava
0 likes · 8 min read
Choosing and Customizing Thread Pools for Java Performance Testing
Code Ape Tech Column
Code Ape Tech Column
Feb 5, 2025 · Backend Development

Handling Exceptions in Java ThreadPool: submit vs execute and Custom Solutions

This article explains why exceptions submitted to a Java thread pool via submit are silent, how to retrieve them using Future.get(), compares submit and execute behaviors, and presents three practical solutions—including try‑catch, Thread.setDefaultUncaughtExceptionHandler, and overriding afterExecute—to reliably capture and process thread pool errors.

ConcurrencyException HandlingExecutorService
0 likes · 14 min read
Handling Exceptions in Java ThreadPool: submit vs execute and Custom Solutions
FunTester
FunTester
Oct 31, 2024 · Backend Development

Understanding Java ExecutorService: Core Concepts, Thread Pools, and Practical Usage

This article explains how Java's ExecutorService abstracts and simplifies asynchronous task execution, covering core features, thread‑pool configurations, task submission methods, future management, shutdown procedures, rejection policies, and real‑world code examples for network requests, image processing, and background tasks.

Best PracticesConcurrencyExecutorService
0 likes · 20 min read
Understanding Java ExecutorService: Core Concepts, Thread Pools, and Practical Usage
macrozheng
macrozheng
Oct 24, 2024 · Backend Development

Master Java Thread Pools: Boost Performance and Avoid Resource Pitfalls

This article explains why creating a thread for each task is inefficient, introduces thread pools as a solution, compares execution times with code examples, details ThreadPoolExecutor's core interfaces, constructors, execution flow, rejection policies, state transitions, and provides practical usage patterns and best‑practice recommendations for Java backend development.

Backend DevelopmentConcurrencyExecutorService
0 likes · 28 min read
Master Java Thread Pools: Boost Performance and Avoid Resource Pitfalls
Code Ape Tech Column
Code Ape Tech Column
Aug 26, 2024 · Backend Development

Handling Exceptions in Java ThreadPool: submit vs execute and Custom Solutions

This article explains why exceptions thrown by tasks submitted to a Java thread pool behave differently with submit and execute, demonstrates how to capture those exceptions using Future.get, try‑catch, Thread.setDefaultUncaughtExceptionHandler, and by overriding afterExecute, and provides complete code examples for each approach.

ConcurrencyExceptionHandlingExecutorService
0 likes · 13 min read
Handling Exceptions in Java ThreadPool: submit vs execute and Custom Solutions
Selected Java Interview Questions
Selected Java Interview Questions
Jul 7, 2024 · Backend Development

Understanding Thread Pool Shutdown and Garbage Collection in Java

This article explains why a Java thread pool with many waiting threads does not release resources, how calling shutdown or shutdownNow interrupts idle workers, how the ThreadPoolExecutor internals handle interruptions, and why proper shutdown is essential to allow both threads and the pool itself to be garbage‑collected.

ConcurrencyExecutorServiceGarbageCollection
0 likes · 11 min read
Understanding Thread Pool Shutdown and Garbage Collection in Java
Cognitive Technology Team
Cognitive Technology Team
Jun 10, 2024 · Backend Development

Gracefully Shutting Down a Thread Pool in Java

To gracefully shut down a Java thread pool, use ExecutorService's shutdown() to reject new tasks, awaitTermination() to wait for running tasks with optional timeout, handle exceptions, and optionally invoke shutdownNow() for forced termination, as illustrated by code examples from Dubbo3 and RocketMQ.

ConcurrencyExecutorServiceGracefulShutdown
0 likes · 4 min read
Gracefully Shutting Down a Thread Pool in Java
Rare Earth Juejin Tech Community
Rare Earth Juejin Tech Community
May 17, 2024 · Backend Development

Understanding and Optimizing Java Thread Pools: Creation, Configuration, and Monitoring

This article explains why threads are essential for performance, how to create and configure Java thread pools using the Executors utility, distinguishes CPU, IO, and scheduled pool types, and demonstrates monitoring techniques for latency and deadlock detection with practical code examples.

CPUConcurrencyExecutorService
0 likes · 25 min read
Understanding and Optimizing Java Thread Pools: Creation, Configuration, and Monitoring
JD Tech
JD Tech
Apr 15, 2024 · Backend Development

How Java Thread Pools Handle Exceptions: execute vs submit

This article investigates how Java's java.util.concurrent.ExecutorService thread pools react to exceptions when tasks are submitted via execute versus submit, providing source‑code experiments, observed outcomes, and a detailed analysis of the underlying JDK implementation.

ConcurrencyExceptionHandlingExecutorService
0 likes · 8 min read
How Java Thread Pools Handle Exceptions: execute vs submit
Spring Full-Stack Practical Cases
Spring Full-Stack Practical Cases
Mar 6, 2024 · Backend Development

Mastering Java 8 CompletableFuture: Async Patterns and Best Practices

This article introduces Java 8's CompletableFuture class, compares it with Future, demonstrates basic Future usage, then explores advanced asynchronous patterns—including CompletionService, chaining, exception handling, combining tasks, and various utility methods—providing code examples and execution results to illustrate each concept.

CompletableFutureConcurrencyExecutorService
0 likes · 15 min read
Mastering Java 8 CompletableFuture: Async Patterns and Best Practices
Architect's Guide
Architect's Guide
Feb 9, 2024 · Backend Development

How to Capture Exceptions from Java ThreadPool Tasks: submit vs execute and Three Solutions

This article explains why exceptions from tasks submitted to a Java ThreadPool using submit are not printed, how execute shows them, and presents three practical approaches—try‑catch within the task, a custom Thread.setDefaultUncaughtExceptionHandler, and overriding afterExecute—to reliably obtain and handle those exceptions.

ConcurrencyExceptionHandlingExecutorService
0 likes · 14 min read
How to Capture Exceptions from Java ThreadPool Tasks: submit vs execute and Three Solutions
Full-Stack Internet Architecture
Full-Stack Internet Architecture
Dec 26, 2023 · Backend Development

Understanding Java Thread Pools: Creation, Execution Flow, Advantages, and Common Implementations

This article introduces Java thread pools, explaining their purpose, creation using ThreadPoolExecutor, execution flow, advantages such as resource reuse and management, common blocking queues, rejection policies, and provides multiple code examples of various pool types and a comprehensive monitoring example.

BlockingQueueConcurrencyExecutorService
0 likes · 11 min read
Understanding Java Thread Pools: Creation, Execution Flow, Advantages, and Common Implementations
Code Ape Tech Column
Code Ape Tech Column
Nov 21, 2023 · Backend Development

Understanding Java CompletionService: Prioritizing the First Completed Task

This article explains the purpose and implementation of Java's CompletionService, compares it with ExecutorService, walks through its source code and key methods, and demonstrates typical usage patterns for efficiently retrieving the earliest completed asynchronous results.

CompletionServiceConcurrencyExecutorService
0 likes · 12 min read
Understanding Java CompletionService: Prioritizing the First Completed Task
Code Ape Tech Column
Code Ape Tech Column
Oct 20, 2023 · Backend Development

Handling Exceptions in Java ThreadPool: submit vs execute and Practical Solutions

This article explains why exceptions submitted to a Java ThreadPool via submit are not printed, how to retrieve them using Future.get(), and presents three practical solutions—including try‑catch, Thread.setDefaultUncaughtExceptionHandler, and overriding afterExecute—to reliably capture and process thread pool exceptions.

ConcurrencyExceptionHandlingExecutorService
0 likes · 15 min read
Handling Exceptions in Java ThreadPool: submit vs execute and Practical Solutions
Architect's Tech Stack
Architect's Tech Stack
Aug 13, 2023 · Backend Development

Handling Exceptions in Java Thread Pools: submit vs execute and Custom Strategies

This article explains why tasks submitted with ExecutorService.submit silently swallow exceptions, how ExecutorService.execute prints them, and presents three practical solutions—including try‑catch, a custom ThreadFactory with UncaughtExceptionHandler, and overriding afterExecute—to reliably capture and process thread‑pool errors in Java.

ConcurrencyExceptionHandlingExecutorService
0 likes · 14 min read
Handling Exceptions in Java Thread Pools: submit vs execute and Custom Strategies
360 Quality & Efficiency
360 Quality & Efficiency
Mar 31, 2023 · Backend Development

Understanding ThreadPoolExecutor: Key Parameters and Source Code Analysis

This article explains the purpose of using thread pools in Java projects, details each important parameter of ThreadPoolExecutor, and provides a thorough walkthrough of its core source code, including constructors, task submission, execution, shutdown mechanisms, and internal worker management, helping developers understand and debug thread pool behavior.

Backend DevelopmentExecutorServiceJava Concurrency
0 likes · 17 min read
Understanding ThreadPoolExecutor: Key Parameters and Source Code Analysis