Java Multithreading: Complete Implementation Guide with Examples
Java provides several mechanisms for creating and managing multithreaded applications. This guide covers all official approaches, from basic to advanced, with practical examples and comparison.
Overview of Implementation Methods
Java defines two fundamental approaches for multithreaded programming, though real-world applications typically use o ...
Posted on Thu, 18 Jun 2026 18:01:36 +0000 by cirko
Using Strings as Synchronization Locks in Java
Using Strings as Synchronization Locks in Java
In Java, the String class possesses unique characteristics due to its implementation of the string constant pool. Although the implementation details changed in JDK 1.8 and later versions, the fundamental behavior remains consistent.
This distinctive feature allows us to utilize String objects as s ...
Posted on Thu, 18 Jun 2026 18:00:08 +0000 by Leppy
Contrasting CountDownLatch and CyclicBarrier in Java Concurrency
The fundamental distinction between CountDownLatch and CyclicBarrier lies in which thread gets blocked. When using CountDownLatch, the await() method is typically invoked by the main or coordinating thread, causing it to block until worker threads signal completion via countDown(). In contrast, CyclicBarrier has the worker threads themselves ca ...
Posted on Thu, 18 Jun 2026 17:35:41 +0000 by Pinkmischief
Understanding Multiprocessing and Multithreading Concepts
A process represents an independent executable program unit that contains one or more threads. A thread serves as the fundamental execusion unit within a process and represents the smallest schedulable unit by the operating system.
Multithreading
Multithreading enables concurrent execution of multiple threads within a single process.
Advantages ...
Posted on Thu, 18 Jun 2026 16:44:22 +0000 by bluestar
Java Thread Pool Architecture: Interfaces, Execution Flow, and Core Concepts
Thread Pool Overview
A thread pool manages a collection of worker threads that are reused to execute multiple tasks. Instead of creating new threads for each task, the thread pool reuses existing threads, reducing the overhead of thread creation and destruction.
Core Interfaces and Implementations
ExecutorService Interface
The ExecutorService i ...
Posted on Wed, 17 Jun 2026 18:11:35 +0000 by Cronje
Using Semaphores to Enforce Exclusive Access to an LED Device in Linux Kernel Driver
This example demonstrates how to implement a GPIO-controlled LED driver that ensures only one user process can access the LED at a time using a counting semaphore initialized to 1 (binary semaphore). The semaphore is acquired in the open() handler and released in the release() handler, effectively serializign access across multiple processes.
D ...
Posted on Tue, 16 Jun 2026 17:08:44 +0000 by Distant_storm
Internals of MySQL Locking Mechanisms and Row-Level Lock Algorithms
MySQL Lock Granularity and Types
In MySQL, locking mechanisms are categorized by their scope into three primary types: global locks, table-level locks, and row-level locks.
Global Locking
Applying a global lock places the entire database instance into a read-only state. This is historically used for logical full-database backups to ensure consi ...
Posted on Tue, 16 Jun 2026 17:05:27 +0000 by rusbb
Dynamic ThreadPoolExecutor Parameter Configuration in Java
ThreadPoolExecutor provides seven core parameters that control thread pool behavior:
Core Parameters
corePoolSize: The number of threads to keep in the pool even when idle, unless allowCoreThreadTimeOut is enabled
maximumPoolSize: The maximum number of threads allowed in the pool
keepAliveTime: The maximum time excess threads (beyond corePoolS ...
Posted on Tue, 16 Jun 2026 16:56:07 +0000 by thessoro
Understanding Java Thread States and Transitions
Overview of Thread States in Java
Thread states form the foundation of concurrent programming in Java. The JDK defines six primary thread states through the java.lang.Thread.State enum. These states reflect different phases of a thread's lifecycle, influenced by synchronization and blocking behaviors.
Six Core Thread States
The official Thread. ...
Posted on Sun, 14 Jun 2026 16:33:51 +0000 by jamesl73
Analyzing Memory Risks in Java's newFixedThreadPool and newCachedThreadPool
Memory Saturation in Fixed Thread Pools
When instantiating a thread pool via Executors.newFixedThreadPool(n), the underlying implementation utilizes an unbounded LinkedBlockingQueue. This design creates a specific failure mode where the queue can grow indefinitely if the task production rate outpaces the consumption rate of the fixed number of ...
Posted on Sat, 13 Jun 2026 16:39:10 +0000 by André D