Tag

Thread Safety

1 views collected around this technical thread.

Spring Full-Stack Practical Cases
Spring Full-Stack Practical Cases
May 15, 2025 · Fundamentals

Mastering Thread‑Safe Classes in Java: 6 Proven Design Strategies

This article explains what makes a class thread‑safe in Java, illustrates common race‑condition pitfalls with sample code, and presents six practical design strategies—including stateless, immutable, synchronized, volatile, concurrent collections, thread‑confinement, and defensive copying—to help developers build robust, high‑performance concurrent applications.

ImmutableJavaSynchronization
0 likes · 11 min read
Mastering Thread‑Safe Classes in Java: 6 Proven Design Strategies
macrozheng
macrozheng
May 7, 2025 · Backend Development

Mastering Date and Time Handling in Java: Thread Safety, Time Zones, and Performance

This article explores common pitfalls in Java date handling, explains thread‑unsafe SimpleDateFormat issues, demonstrates safe alternatives with ThreadLocal, Java 8 Time API, and zone‑aware calculations, and provides performance‑optimized patterns for high‑throughput applications.

DateTimeJavaSpring Boot
0 likes · 10 min read
Mastering Date and Time Handling in Java: Thread Safety, Time Zones, and Performance
Java Tech Enthusiast
Java Tech Enthusiast
Mar 4, 2025 · Backend Development

When to Use volatile with ConcurrentHashMap and Spring Bean Thread Safety

A ConcurrentHashMap is internally thread‑safe, so a volatile declaration is only required when its reference may be reassigned (or the field is final), while Spring singleton beans with mutable fields are not thread‑safe and should be made stateless, prototype‑scoped, or synchronized for composite operations.

ConcurrentHashMapJavaSpring
0 likes · 13 min read
When to Use volatile with ConcurrentHashMap and Spring Bean Thread Safety
Architecture Development Notes
Architecture Development Notes
Feb 4, 2025 · Fundamentals

Mastering Rust’s Send and Sync Traits for Safe Concurrency

Explore how Rust’s Send and Sync marker traits guarantee thread‑safe ownership transfer and shared references, with clear explanations, practical code examples, custom type implementations, common pitfalls, and performance considerations to help you write reliable concurrent programs.

ARCMutexRust
0 likes · 8 min read
Mastering Rust’s Send and Sync Traits for Safe Concurrency
Top Architect
Top Architect
Jan 19, 2025 · Backend Development

Understanding Kafka Consumer: Offset Management, Rebalance, Partition Assignment, and Thread Safety

This article provides a comprehensive technical walkthrough of KafkaConsumer, covering Java configuration code, delivery semantics (at‑most‑once, at‑least‑once, exactly‑once), offset commit strategies, rebalance mechanisms, partition assignment algorithms, thread‑safety concerns, and internal poll implementation, followed by unrelated promotional content.

ConsumerKafkaOffset Management
0 likes · 16 min read
Understanding Kafka Consumer: Offset Management, Rebalance, Partition Assignment, and Thread Safety
Architecture & Thinking
Architecture & Thinking
Jan 8, 2025 · Fundamentals

Mastering Java’s synchronized: How Object and Class Locks Control Threads

This article explains the purpose and usage of Java’s synchronized keyword, covering object locks, method locks, synchronized blocks, and class locks, along with detailed code examples that demonstrate how threads acquire and release locks to ensure data consistency in multithreaded environments.

JavaThread Safetyconcurrency
0 likes · 11 min read
Mastering Java’s synchronized: How Object and Class Locks Control Threads
IT Services Circle
IT Services Circle
Jan 4, 2025 · Backend Development

Is std::cout Thread‑Safe? Understanding Data Races, Race Conditions, and Practical Solutions in C++

This article examines whether std::cout is thread‑safe, explains the concepts of data race and race condition, demonstrates how interleaved output can occur in multithreaded C++ programs, and presents several solutions—including mutexes, custom wrappers, and C++20 std::osyncstream—to ensure orderly output.

C++Data RaceMutex
0 likes · 10 min read
Is std::cout Thread‑Safe? Understanding Data Races, Race Conditions, and Practical Solutions in C++
Test Development Learning Exchange
Test Development Learning Exchange
Dec 28, 2024 · Backend Development

Using asyncio call_soon, call_at, call_later, and call_soon_threadsafe in Python

This article explains how Python's asyncio library schedules callbacks with call_soon, call_at, call_later, and call_soon_threadsafe, providing detailed usage descriptions and multiple example code snippets that demonstrate immediate, absolute‑time, relative‑time, and thread‑safe task scheduling within an event loop.

Event LoopPythonThread Safety
0 likes · 6 min read
Using asyncio call_soon, call_at, call_later, and call_soon_threadsafe in Python
FunTester
FunTester
Dec 26, 2024 · Fundamentals

Chapter 2 – Common Java Multithreading Utilities and the synchronized Keyword

This chapter introduces advanced Java multithreading concepts, explaining thread safety, the synchronized keyword, various synchronization techniques, and practical code examples such as object‑level, class‑level, method‑level synchronization and double‑checked locking to help solve concurrency problems in performance testing.

JavaSynchronizationThread Safety
0 likes · 15 min read
Chapter 2 – Common Java Multithreading Utilities and the synchronized Keyword
FunTester
FunTester
Dec 3, 2024 · Backend Development

Why i++ Is Not Thread‑Safe and How to Demonstrate It with Java, Byteman, and Synchronization

The article explains that the Java increment operation i++ is not atomic, describes the three‑step execution that leads to race conditions in multithreaded environments, and shows how to reproduce and fix the issue using synchronized blocks, AtomicInteger, and Byteman fault‑injection scripts.

AtomicIntegerBytemanJava
0 likes · 10 min read
Why i++ Is Not Thread‑Safe and How to Demonstrate It with Java, Byteman, and Synchronization
Python Programming Learning Circle
Python Programming Learning Circle
Nov 5, 2024 · Fundamentals

Implementing the Singleton Pattern in Python: Multiple Approaches and Thread Safety

This article explains the Singleton design pattern in Python, covering various implementation methods—including modules, decorators, classic classes, __new__ method, and metaclasses—while demonstrating thread‑safety concerns and solutions with locking, and provides complete code examples for each approach.

ModulePythonThread Safety
0 likes · 10 min read
Implementing the Singleton Pattern in Python: Multiple Approaches and Thread Safety
Rare Earth Juejin Tech Community
Rare Earth Juejin Tech Community
Sep 17, 2024 · Backend Development

In‑Depth Explanation of Java ConcurrentHashMap Core Principles and Source Code

This article provides a comprehensive analysis of Java's ConcurrentHashMap, covering its underlying data structures, key attributes, core components such as Node, ForwardingNode, TreeBin, and TreeNode, and detailed explanations of the put, get, hash, and resizing algorithms with annotated source code examples.

ConcurrentHashMapData StructuresHashMap
0 likes · 17 min read
In‑Depth Explanation of Java ConcurrentHashMap Core Principles and Source Code
Top Architect
Top Architect
Aug 7, 2024 · Backend Development

Kafka Consumer Deep Dive: Offset Management, Rebalance Strategies, and Thread Safety

This article explains Kafka consumer semantics such as at‑most‑once, at‑least‑once and exactly‑once delivery, shows how to configure and commit offsets, describes the rebalance process and partition‑assignment strategies, and discusses thread‑safety and task scheduling with illustrative Java code examples.

ConsumerJavaKafka
0 likes · 17 min read
Kafka Consumer Deep Dive: Offset Management, Rebalance Strategies, and Thread Safety
Rare Earth Juejin Tech Community
Rare Earth Juejin Tech Community
Jul 1, 2024 · Backend Development

Resolving Data Contamination in Multithreaded Security Testing by Redesigning Class Attributes in Python

This article explains how using a shared class attribute to store open ports in a Python security‑testing framework can cause data contamination across threads, demonstrates the problem with example code, and presents three solutions—reinitializing the attribute, using contextvars, and employing threading.local—to ensure thread‑local isolation and accurate port scanning.

Class AttributesContextVarPython
0 likes · 10 min read
Resolving Data Contamination in Multithreaded Security Testing by Redesigning Class Attributes in Python
Cognitive Technology Team
Cognitive Technology Team
Jun 23, 2024 · Fundamentals

Understanding Fail-Fast Iterators and ConcurrentModificationException in Java Collections

The article explains why fail‑fast iterators throw ConcurrentModificationException when a collection is modified during iteration, outlines two common scenarios that trigger the exception, and presents both incorrect and correct Java code examples along with strategies such as avoiding modifications, using synchronization, iterator.remove(), or switching to fail‑safe concurrent collections.

CollectionsConcurrentModificationExceptionFail-Fast Iterator
0 likes · 5 min read
Understanding Fail-Fast Iterators and ConcurrentModificationException in Java Collections
Cognitive Technology Team
Cognitive Technology Team
Jun 8, 2024 · Fundamentals

Why ConcurrentHashMap Disallows Null Keys and Values in Java

ConcurrentHashMap forbids null keys and values because allowing nulls creates ambiguous results in concurrent environments, making it impossible to distinguish between a missing entry and an entry explicitly mapped to null, which could compromise thread safety, as explained by Doug Lea’s design rationale.

ConcurrentHashMapJavaNULL
0 likes · 4 min read
Why ConcurrentHashMap Disallows Null Keys and Values in Java
Test Development Learning Exchange
Test Development Learning Exchange
May 27, 2024 · Fundamentals

Implementing the Singleton Pattern in Python: Multiple Approaches

This article explains the Singleton design pattern in Python and presents seven implementation techniques—including module‑level variables, module instances, decorators, metaclasses, class methods, and thread‑safe approaches—complete with code examples and guidance on choosing the appropriate method.

PythonThread Safetydesign pattern
0 likes · 5 min read
Implementing the Singleton Pattern in Python: Multiple Approaches
IT Services Circle
IT Services Circle
May 16, 2024 · Fundamentals

Thread Safety Explained: Private vs Shared Resources and Practical Guidelines

This article demystifies thread safety by comparing private and shared resources, defining when code is thread‑safe, illustrating common pitfalls with C/C++ examples, and presenting practical techniques such as using thread‑local storage, read‑only globals, atomic operations, and synchronization to write reliable multithreaded programs.

Thread Safetyatomic operationsconcurrency
0 likes · 16 min read
Thread Safety Explained: Private vs Shared Resources and Practical Guidelines
Architect's Guide
Architect's Guide
Apr 28, 2024 · Backend Development

Kafka Consumer Usage Example and Deep Dive into Offset Management, Rebalance, and Thread Safety

This article presents a Java Kafka consumer example, explains offset semantics (at‑most‑once, at‑least‑once, exactly‑once), details consumer rebalance mechanisms, partition assignment strategies, thread‑safety considerations, and showcases core poll, heartbeat, and auto‑commit implementations with accompanying code snippets.

ConsumerJavaKafka
0 likes · 14 min read
Kafka Consumer Usage Example and Deep Dive into Offset Management, Rebalance, and Thread Safety