Understanding Java's Volatile Keyword in Multithreading Environments

In our previous discussion on Java's memory model, we explored the three fundamental characteristics of threads and the happens-before principle. This article focuses on the volatile keyword, examining its underlying mechanisms and practical applications. By the end, you'll have a deeper understanding of how volatile works and its appropriate u ...

Posted on Mon, 08 Jun 2026 18:43:49 +0000 by tanju

Python Concurrency: Threads, Processes, and Thread Pools

Global Interpreter Lock in Python The Global Interpreter Lock (GIL) is a mutex that protects access to Python objects, preventing multiple native threads from executing Python bytecodes at the same time. In CPython, the standard implementation of Python, the GIL ensures that only one thread executes at a time. This means that even with multip ...

Posted on Sun, 07 Jun 2026 17:04:27 +0000 by dhvani

Multithreading in .NET Core

Process: A process is not a physical entity; it is a computer concept (virtual) that represents the collection of all computing resources (CPU, memory, disk, network, etc.) used when a program is running. Thread: Also a computer concept (virtual). It is the smallest execution flow of a process (any operation response requires an execution flow) ...

Posted on Sat, 06 Jun 2026 17:54:26 +0000 by eduard

Java Multi-threaded Circular Printing

This article demonstrates several approaches to implement circular printing among multiple threads in Java. The goal is to have three threads print their respective numbeers (0, 1, 2) in order, cycling through 10 times. 1. Flag Variable + Mutex Lock import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; public ...

Posted on Fri, 05 Jun 2026 17:01:46 +0000 by MikeyNoedel

Understanding the Implementation Principles of Java's Synchronized Mechanism

Understanding the Internal Implementation of synchronized (Deep Dive with Monitor) Core Premise: Locks are Bound to Objects The synchronized keyword in Java, whether applied to methods or code blocks, ultimately associates with a specific object. Instance methods bind to the current object instance (this), static methods bind to the Class obj ...

Posted on Mon, 01 Jun 2026 17:30:19 +0000 by hws

Using Selectors in a Multithreaded Environment and Understanding IO Models

1. Using Selector in a Multithreaded Environment 1-1 Why Multi-threading Optimization? Although a single thread with a selector can manage multiple channels' events, it has the following drawbacks: Drawback 1: Multi-core CPUs are wasted. Drawback 2: A time-consuming event can delay the processing of other events. Single-threaded event processi ...

Posted on Sun, 31 May 2026 17:58:08 +0000 by ReVeR

Implementing Asynchronous Operations in C# via Delegate Patterns

Overview of Asynchronous Execution in .NET The .NET Framework provides mechanisms to execute methods asynchronously without blocking the calling thread. This is achieved by defining a delegate matching the signature of the target method. The Common Language Runtime (CLR) automatically generates BeginInvoke and EndInvoke methods for any given de ...

Posted on Sat, 30 May 2026 21:35:50 +0000 by andreea115

Multithreaded Producer-Consumer with Synchronized in Java

Problem Statement We need two threads to operate on a shared variable. One thread increments the variable by 1, the other decrements it by 1, and they must alternate. The initial value is 0. In other words, two threads perform alternating increment and decrement operations on a common resource. Let's get started. First, define the resource clas ...

Posted on Tue, 26 May 2026 19:25:12 +0000 by ron8000

Multithreaded C Implementation with Regex and File I/O for Extracting Numeric Data

This article demonstrates a C program that reads a source file line by line, extracts numeric segments from each line using regular expressions, and writes the results to a target file. The implementation uses two threads that alternate execution, with a mutex protecting shared data. The gather thread is responsible for reading lines from the s ...

Posted on Tue, 26 May 2026 18:04:04 +0000 by ionik

Thread-Safe Singleton Patterns in Java

Singleton Pattern Overview The singleton pattern ensures that a class has exactly one instance and provides a global point of access to it. This is especial valuable when managing shared resources—such as data base connection pools, configuration managers, or large in-memory caches—where duplication would waste memory or cause inconsistent stat ...

Posted on Sat, 23 May 2026 15:59:53 +0000 by hackerkts