Java Thread Implementation and Thread Pool Usage
Two primary approaches exist for creating new execution threads in Java:
Extending the Thread class:
Define a sucblass of Thread and override its run() method.
Instantiate the subclass and envoke start() to initiate thread execution.
public class CustomThread extends Thread {
@Override
public void run() {
for (int i = 0; i ...
Posted on Sun, 30 Aug 2026 16:37:12 +0000 by EPCtech
ThreadPoolExecutor Internals: Worker Lifecycle and Task Scheduling Mechanics
AbstractExecutorService Foundation
The ThreadPoolExecutor inherits from AbstractExecutorService, which provides default implementations for ExecutorService interface methods. This abstract base handles task submission utilities including submit, invokeAny, and invokeAll by wrapping tasks into Future objects.
The submission mechanism follows the ...
Posted on Sun, 30 Aug 2026 16:13:45 +0000 by ndorfnz
Java Volatile, Synchronization, and Double-Checked Locking Explained
The volatile keyword is often misunderstood as a complete thread‑safety mechanism. In reality, volatile provides only visibility and ordering guarantees; it does not ensure atomicity or prevent race conditions. When a variable is declared volatile, any write to it is immediately visible to other threads, and the JVM does not reorder memory oper ...
Posted on Fri, 28 Aug 2026 16:40:20 +0000 by Lexas
JDK Thread Pool invokeAll Blocking Issue with Silent Rejection Policies
JDK Thread Pool Rejection Policies
The JDK standard thread pool provides four rejection policies:
AbortPolicy: Discards the task and throws a RejectedExecutionException — the default policy.
DiscardOldestPolicy: Discards the oldest unprocessed task in the queue and attempts to execute the current task.
CallerRunsPolicy: The calling thread exec ...
Posted on Wed, 26 Aug 2026 16:28:32 +0000 by praxiz
Practical Java Development Tips and Internal Mechanics
Inspect class lifecycle events during runtime by appending specific flags to your JVM startup configuration:
-verbose:class -XX:+TraceClassLoading -XX:+TraceClassUnloading
Detailed garbage collection behavior can be monitored using -XX:+PrintGCDetails. To enforce strict heap boundaries, allocate fixed initial and maximum sizes alongside a defi ...
Posted on Tue, 25 Aug 2026 16:38:48 +0000 by alsouno
Implementing BBR Congestion Control in Kratos Framework
BBR (Bottleneck Bandwidth and Round-trip time) is a congestion control algorithm originally developed by Google. In the context of rate limiting, BBR has been adapted to provide dynamic throttling by automatically adjusting request concurrency to balance system throughput and response times.
Core Principles of BBR Rate Limiting
The BBR algorith ...
Posted on Tue, 25 Aug 2026 16:22:01 +0000 by vandalite
Demystifying Java ConcurrentHashMap Internals
Core Data Structures and Constants
The internal mechanics rely heavily on bitwise operations and volatile state variables. The maximum capacity is constrained to a power of two to allow bitwise masking for index calculation.
private static final int MAX_CAPACITY_LIMIT = 1 > 16)) & POSITIVE_MASK;
}
Slot indexing uses a bitwise AND operation wi ...
Posted on Mon, 24 Aug 2026 16:21:33 +0000 by creocast
Comparing Concurrency Patterns in C#: BlockingCollection vs ConcurrentBag vs BoundedChannel
Introduction
In .NET development, selecting the correct data structure for the producer-consumer pattern is crucial for application stability and performance. While BlockingCollection<T>, ConcurrentBag<T>, and BoundedChannel (via Channel.CreateBounded) can all facilitate data exchange between threads, they fundamentally differ in th ...
Posted on Sun, 23 Aug 2026 16:51:42 +0000 by cavolks
Building Multi-Core HTTP Servers with Node.js Cluster
The Cluster Module
Since the Node.js runtime operates on a single thread, handling high-concurrency traffic requires strategies to maximize hardware utilization. The cluster module allows a Node.js application to spawn multiple child processes (workers) that share the same server port. This enables the application to distribute incoming connect ...
Posted on Sat, 22 Aug 2026 16:22:27 +0000 by cinos11
Dining Philosophers Problem: Deadlock Analysis and Java Solutions
The Dining Philosophers problem, introduced by Edsger Dijkstra in 1971, models synchronization challenges in concurrent systems. Originally conceived as five computers attempting to access five shared tape drives, it was later reformulated by C.A.R. Hoare into the classic version involving philosophers and forks.
The problem involves five philo ...
Posted on Sat, 22 Aug 2026 16:18:07 +0000 by cleromancer