Tagged articles
221 articles
Page 2 of 3
Java Interview Crash Guide
Java Interview Crash Guide
Oct 18, 2021 · Backend Development

Why Thread Safety Fails in Java and How to Ensure It

This article explains how variable sharing in multithreaded Java programs leads to thread‑unsafe behavior, explores the JVM memory model and stack frame structure, and demonstrates practical ways to achieve thread safety by keeping variables thread‑local or using proxy objects.

JVMconcurrencyjava
0 likes · 10 min read
Why Thread Safety Fails in Java and How to Ensure It
Python Programming Learning Circle
Python Programming Learning Circle
Oct 7, 2021 · Fundamentals

Thread‑Safe Counter Implementations in Python: Single‑Thread, Fast‑Read, and Fast‑Write Approaches

This article explains how to implement simple counters in Python, demonstrates why a naïve single‑thread counter is not safe for concurrent use, and presents three thread‑safe alternatives—using a lock, leveraging the GIL with itertools.count, and a combined fast‑read/fast‑write design—along with a performance comparison.

GILthread safety
0 likes · 8 min read
Thread‑Safe Counter Implementations in Python: Single‑Thread, Fast‑Read, and Fast‑Write Approaches
Programmer DD
Programmer DD
Sep 26, 2021 · Backend Development

Mastering ThreadLocal in Java: When and How to Use It Safely

This article explains the two primary use cases of ThreadLocal in Java—providing each thread with its own exclusive object and sharing request‑scoped data across methods—while covering implementation details, memory‑leak risks, and best‑practice cleanup techniques.

ThreadLocalbackend-developmentconcurrency
0 likes · 10 min read
Mastering ThreadLocal in Java: When and How to Use It Safely
Programmer DD
Programmer DD
Sep 14, 2021 · Backend Development

Why Spring MVC Controllers Are Singleton and How to Ensure Thread Safety

This article explains that Spring MVC controllers are singleton by default, illustrates the thread‑safety problems caused by shared instance variables with concrete code examples, and provides practical solutions such as avoiding state, using prototype scope, ThreadLocal, or AtomicInteger to make controllers safe under high concurrency.

ControllerSingletonSpring MVC
0 likes · 6 min read
Why Spring MVC Controllers Are Singleton and How to Ensure Thread Safety
Selected Java Interview Questions
Selected Java Interview Questions
Sep 12, 2021 · Backend Development

Understanding Java ConcurrentHashMap: Initialization, Null Handling, Resizing, Data Structure, Operations, and Thread‑Safety

This article explains Java 1.8 ConcurrentHashMap’s default capacity, null‑key/value restrictions, resizing behavior, internal array‑list‑tree structure, node fields, put and get processes, thread‑safety mechanisms, iterator consistency, and differences between JDK 7 and JDK 8 implementations.

ConcurrentHashMapJava 8java
0 likes · 9 min read
Understanding Java ConcurrentHashMap: Initialization, Null Handling, Resizing, Data Structure, Operations, and Thread‑Safety
ITPUB
ITPUB
Jul 29, 2021 · Fundamentals

Mastering Java’s Happens‑Before Principle and Memory Model

This article explains the Java Memory Model, how threads interact with main and working memory, and details the happens‑before rules—including program order, monitor, volatile, thread start, join, and transfer—to help developers understand visibility and ordering challenges in concurrent Java programs.

Happens-beforeJMMMemory Model
0 likes · 10 min read
Mastering Java’s Happens‑Before Principle and Memory Model
New Oriental Technology
New Oriental Technology
May 31, 2021 · Backend Development

A Comprehensive Guide to Java Concurrency and Synchronization Mechanisms

This article provides an in-depth exploration of Java concurrency and synchronization mechanisms, detailing the evolution of the Java Memory Model, explaining core concepts like volatile, CAS, synchronized, and park/unpark, and illustrating their practical applications through code examples and JVM optimization insights.

CASJVM OptimizationJava concurrency
0 likes · 15 min read
A Comprehensive Guide to Java Concurrency and Synchronization Mechanisms
Full-Stack Internet Architecture
Full-Stack Internet Architecture
May 18, 2021 · Backend Development

Understanding Thread Safety Issues with SimpleDateFormat and Solutions in Java

This article explains why SimpleDateFormat is not thread‑safe in Java, demonstrates the problem with multithreaded examples, and presents five practical solutions—including local variables, synchronized blocks, explicit locks, ThreadLocal, and the modern DateTimeFormatter—along with their advantages and drawbacks.

DateTimeFormatterSimpleDateFormatconcurrency
0 likes · 13 min read
Understanding Thread Safety Issues with SimpleDateFormat and Solutions in Java
Full-Stack Internet Architecture
Full-Stack Internet Architecture
May 15, 2021 · Backend Development

Using ThreadLocal in Java: Scenarios, Thread‑Safety Problems, and Practical Solutions

This article explains why ThreadLocal is both simple and tricky to use, demonstrates common pitfalls when formatting dates with SimpleDateFormat in multithreaded environments, analyzes thread‑safety issues, and provides practical solutions using synchronized blocks, ThreadLocal, and its advanced initialization methods for clean and efficient concurrent code.

ThreadLocalconcurrencyjava
0 likes · 20 min read
Using ThreadLocal in Java: Scenarios, Thread‑Safety Problems, and Practical Solutions
FunTester
FunTester
May 6, 2021 · Backend Development

Do Thread‑Safe Classes and synchronized Really Slow Down Performance Tests?

This article examines how adding Java thread‑safe classes and the synchronized keyword influences QPS in performance testing, presenting code modifications, benchmark results for 20 and 40 threads, and concluding that their impact on measured throughput is minimal.

Performance TestingQPSSynchronization
0 likes · 8 min read
Do Thread‑Safe Classes and synchronized Really Slow Down Performance Tests?
TAL Education Technology
TAL Education Technology
Apr 8, 2021 · Backend Development

Java Concurrency Programming: Concepts, Tools, and Practical Examples

This comprehensive guide introduces Java concurrency fundamentals, explains common tools and their underlying principles, discusses typical challenges such as thread safety, visibility, and ordering, and provides practical code examples and optimization techniques for building high‑performance multithreaded applications.

concurrencyjavamultithreading
0 likes · 16 min read
Java Concurrency Programming: Concepts, Tools, and Practical Examples
Selected Java Interview Questions
Selected Java Interview Questions
Apr 5, 2021 · Backend Development

Understanding Thread Safety in Java: StringBuilder, StringBuffer, and Servlets

This article explains the thread‑safety differences between StringBuilder and StringBuffer, demonstrates the problems of using mutable shared objects in multithreaded Java code, presents three solutions, and discusses why Servlets are not thread‑safe by default, highlighting visibility and ordering concepts.

Servletbackend-developmentconcurrency
0 likes · 10 min read
Understanding Thread Safety in Java: StringBuilder, StringBuffer, and Servlets
Intelligent Backend & Architecture
Intelligent Backend & Architecture
Apr 2, 2021 · Fundamentals

Master Java Collections: From ArrayList to ConcurrentHashMap Explained

This article provides a comprehensive overview of Java's collection framework, detailing the roles of interfaces, implementations, and algorithms, comparing collections with arrays, describing common List, Set, and Map classes, their underlying data structures, thread‑safety characteristics, and best practices for iteration and usage.

CollectionsConcurrentHashMapData Structures
0 likes · 48 min read
Master Java Collections: From ArrayList to ConcurrentHashMap Explained
FunTester
FunTester
Mar 2, 2021 · Operations

How to Diversify Request Parameters for Robust Performance Testing

This article explains practical techniques for generating varied request parameters—such as random numbers, thread‑safe identifiers, random strings, and upstream data extraction—to avoid identical inputs in multi‑call performance tests and improve test reliability.

Performance Testingautomationjava
0 likes · 12 min read
How to Diversify Request Parameters for Robust Performance Testing
Full-Stack Internet Architecture
Full-Stack Internet Architecture
Feb 18, 2021 · Fundamentals

Comprehensive Guide to the Singleton Pattern in Java: Implementations, Pitfalls, and the Secure Enum Solution

This article explains various Java singleton implementations—including eager, lazy, double‑checked locking, static inner class, and enum—demonstrates their thread‑safety issues, shows how reflection and serialization can break them, and presents the enum approach as a truly safe solution.

ReflectionSingletondesign pattern
0 likes · 11 min read
Comprehensive Guide to the Singleton Pattern in Java: Implementations, Pitfalls, and the Secure Enum Solution
Top Architect
Top Architect
Feb 10, 2021 · Backend Development

Understanding Thread Safety Issues in Java ArrayList and How to Fix Them

This article explains why Java's ArrayList is not thread‑safe, illustrates the two main concurrency problems—array index out‑of‑bounds and element overwriting—through source‑code analysis and multithreaded examples, and presents several practical solutions such as synchronized wrappers, explicit locking, CopyOnWriteArrayList and ThreadLocal.

ArrayListCollectionsCopyOnWriteArrayList
0 likes · 11 min read
Understanding Thread Safety Issues in Java ArrayList and How to Fix Them
FunTester
FunTester
Feb 6, 2021 · Fundamentals

Mastering Java ThreadLocal: Achieve Thread‑Safe Objects Without synchronized

This article explains how Java's ThreadLocal class provides a thread‑local storage mechanism that creates independent object instances for each thread, improving scalability and performance compared to synchronized blocks, and demonstrates its usage with practical code examples and best‑practice guidelines.

ThreadLocalbackend-developmentconcurrency
0 likes · 8 min read
Mastering Java ThreadLocal: Achieve Thread‑Safe Objects Without synchronized
FunTester
FunTester
Jan 15, 2021 · Operations

Customizing Request Marking for Java API Performance Testing

This article explains how to modify a Java search API and write custom performance‑testing scripts that embed unique request marks, enabling precise measurement of each request's response time when header‑based marking is unavailable.

APIBackendScripting
0 likes · 6 min read
Customizing Request Marking for Java API Performance Testing
Su San Talks Tech
Su San Talks Tech
Dec 8, 2020 · Backend Development

How Java's ConcurrentHashMap Delivers High‑Performance Thread Safety

This article explains the internal design of Java's ConcurrentHashMap, covering its evolution from JDK7 to JDK8, the segment‑based locking mechanism, lock‑free reads, CAS operations, table resizing, treeification, and the key classes and methods that enable efficient concurrent access while maintaining thread safety.

CASConcurrentHashMapLock Splitting
0 likes · 42 min read
How Java's ConcurrentHashMap Delivers High‑Performance Thread Safety
Top Architect
Top Architect
Dec 8, 2020 · Backend Development

Understanding Thread Safety of Spring Beans: Singleton vs Prototype Scope

This article explains why Spring beans are not inherently thread‑safe, compares the singleton and prototype scopes, shows how stateless beans can be safe, demonstrates the impact of static fields and injected beans, and provides practical code examples and recommendations for achieving thread safety in Spring applications.

Singletonbeanjava
0 likes · 11 min read
Understanding Thread Safety of Spring Beans: Singleton vs Prototype Scope
ITPUB
ITPUB
Dec 2, 2020 · Backend Development

Why Thread Safety and Reentrancy Matter in C++ Backend Development

The article uses a casual conversation between two backend engineers to introduce multithreading concepts, explain shared vs. private resources, define thread‑safe and reentrant functions, illustrate common pitfalls with code examples, and provide practical guidelines for writing correct concurrent C++ services.

Reentrancybackend-developmentc++
0 likes · 11 min read
Why Thread Safety and Reentrancy Matter in C++ Backend Development
Architecture Digest
Architecture Digest
Nov 8, 2020 · Backend Development

Key Considerations and Implementation Strategies for a Local Cache in Java

This article outlines the essential design considerations for building a local cache—such as data structures, size limits, eviction policies, expiration, thread safety, simple APIs, persistence, and blocking mechanisms—and demonstrates concrete Java implementations with code examples.

eviction policyjavalocal cache
0 likes · 11 min read
Key Considerations and Implementation Strategies for a Local Cache in Java
Full-Stack Internet Architecture
Full-Stack Internet Architecture
Oct 14, 2020 · Fundamentals

Singleton Pattern – Ensuring a Unique Instance in Java

This article explains the definition, class diagram, and multiple Java implementations of the Singleton pattern—including eager, lazy, double‑checked locking, static inner class, and enum approaches—while discussing thread safety, volatile usage, and practical considerations.

design patternenumjava
0 likes · 9 min read
Singleton Pattern – Ensuring a Unique Instance in Java
Su San Talks Tech
Su San Talks Tech
Oct 7, 2020 · Backend Development

8 Proven Java Techniques to Ensure Thread‑Safe Data in Concurrent Apps

This article outlines eight practical Java approaches—including stateless design, immutability, safe publication, volatile fields, synchronized blocks, explicit locks, CAS operations, and ThreadLocal—to guarantee data safety in multithreaded environments, explaining each concept and providing concise code examples.

CASLockSynchronization
0 likes · 6 min read
8 Proven Java Techniques to Ensure Thread‑Safe Data in Concurrent Apps
vivo Internet Technology
vivo Internet Technology
Sep 16, 2020 · Backend Development

How ConcurrentHashMap Guarantees Thread‑Safe Reads and Writes: A Deep Dive into C13Map Internals

This article explains the fundamentals of HashMap, then dissects the internal fields, node‑array safety, read‑path guarantees, write‑path locking, atomic compute methods, resize‑transfer mechanics, traverser design, and bulk‑task support that together make Java's ConcurrentHashMap (C13Map) a highly concurrent, lock‑free data structure.

ConcurrentHashMapData StructuresHashMap
0 likes · 49 min read
How ConcurrentHashMap Guarantees Thread‑Safe Reads and Writes: A Deep Dive into C13Map Internals
Senior Brother's Insights
Senior Brother's Insights
Sep 15, 2020 · Fundamentals

Why Is StringBuilder Not Thread‑Safe? Deep Dive into Java’s Internals

Although StringBuilder and StringBuffer share similar APIs, StringBuilder lacks thread safety because its append method updates shared fields without synchronization, leading to race conditions that can corrupt the internal char array and cause ArrayIndexOutOfBoundsException, as demonstrated by a multithreaded test example.

JVMconcurrencyjava
0 likes · 7 min read
Why Is StringBuilder Not Thread‑Safe? Deep Dive into Java’s Internals
Wukong Talks Architecture
Wukong Talks Architecture
Aug 31, 2020 · Fundamentals

Understanding Thread Safety Issues in Java Collections: ArrayList, HashSet, HashMap and Their Solutions

This article explains why core Java collection classes such as ArrayList, HashSet, and HashMap are not thread‑safe, demonstrates the underlying mechanisms of their initialization and resizing, and presents multiple approaches—including Vector, synchronized wrappers, and CopyOnWrite variants—to achieve safe concurrent access.

ArrayListHashMapconcurrency
0 likes · 16 min read
Understanding Thread Safety Issues in Java Collections: ArrayList, HashSet, HashMap and Their Solutions
Java Backend Technology
Java Backend Technology
Aug 18, 2020 · Backend Development

Why Spring Controllers Are Not Thread‑Safe and How to Fix Them

Spring MVC controllers are singleton by default, which can cause thread‑unsafe behavior when using non‑static member variables; this article demonstrates the issue with example endpoints, shows how prototype scope resolves it, and outlines best practices such as avoiding stateful fields or using ThreadLocal.

Bean ScopeControllerSingleton
0 likes · 5 min read
Why Spring Controllers Are Not Thread‑Safe and How to Fix Them
Top Architect
Top Architect
Aug 6, 2020 · Backend Development

Understanding Spring Controller Bean Scope: Singleton vs Prototype and Thread Safety

This article explains why Spring MVC controllers are singleton by default, demonstrates the thread‑safety issues caused by shared instance variables, shows how to test the behavior with sample code, and presents solutions such as using prototype scope, avoiding member variables, or employing ThreadLocal.

Bean ScopeControllerSingleton
0 likes · 6 min read
Understanding Spring Controller Bean Scope: Singleton vs Prototype and Thread Safety
macrozheng
macrozheng
Aug 6, 2020 · Backend Development

When ‘No‑Comment’ Java Code Triggers a Memory Leak – A ConcurrentHashMap Study

A newly hired architect boasts high‑concurrency expertise but writes un‑commented Java code that misuses ConcurrentHashMap, leading to memory leaks; the ensuing investigation reveals missing equals/hashCode implementations, race conditions in a visit method, and a debate between synchronized blocks and putIfAbsent for safe updates.

ConcurrentHashMapSynchronizationbackend-development
0 likes · 8 min read
When ‘No‑Comment’ Java Code Triggers a Memory Leak – A ConcurrentHashMap Study
Selected Java Interview Questions
Selected Java Interview Questions
Jul 27, 2020 · Backend Development

Understanding Spring Controller Scope and Thread Safety

The article explains why Spring MVC controllers are singleton by default, demonstrates the resulting thread‑unsafe behavior with example code, shows how applying @Scope("prototype") makes them prototype scoped, and provides best‑practice recommendations and a summary of Spring bean scopes.

ControllerSingletonbean
0 likes · 5 min read
Understanding Spring Controller Scope and Thread Safety
FunTester
FunTester
Jul 19, 2020 · Operations

How to Build a Thread‑Safe Global Counter in JMeter with Groovy

This guide explains how to create a globally unique, auto‑incrementing variable in JMeter by using a synchronized Groovy script that leverages the built‑in props object, demonstrates setting an initial value, and compares locked versus unlocked execution results.

Global VariableGroovyJMeter
0 likes · 8 min read
How to Build a Thread‑Safe Global Counter in JMeter with Groovy
Programmer DD
Programmer DD
Jun 29, 2020 · Backend Development

Why Spring Beans Aren’t Thread‑Safe and How ThreadLocal Solves It

This article explains that Spring does not guarantee thread safety for its beans, describes the various bean scopes, clarifies why stateless singleton beans are safe, and shows how ThreadLocal works—including its implementation, usage, and potential memory‑leak pitfalls—so developers can write correct concurrent code.

ThreadLocalconcurrencyjava
0 likes · 17 min read
Why Spring Beans Aren’t Thread‑Safe and How ThreadLocal Solves It
Selected Java Interview Questions
Selected Java Interview Questions
May 9, 2020 · Fundamentals

Java Singleton Pattern: Lazy, Eager, Static Inner Class, Enum, and Double-Checked Locking

This article explains the Java Singleton pattern, covering lazy (thread‑unsafe), eager, static inner‑class, enum, and double‑checked locking implementations, discusses their thread‑safety, performance, and serialization issues, and provides complete code examples for interview preparation.

Singletondesign patterndouble-checked locking
0 likes · 6 min read
Java Singleton Pattern: Lazy, Eager, Static Inner Class, Enum, and Double-Checked Locking
Full-Stack Internet Architecture
Full-Stack Internet Architecture
Apr 26, 2020 · Fundamentals

Understanding ConcurrentHashMap: Implementation Differences between JDK 1.7 and JDK 1.8

This article explains why ConcurrentHashMap provides thread‑safe and high‑performance map operations, compares it with HashMap and Hashtable, and details the architectural changes from JDK 1.7’s segment‑lock design to JDK 1.8’s array‑list‑red‑black‑tree and CAS‑based implementation.

ConcurrentHashMapData StructuresJDK7
0 likes · 7 min read
Understanding ConcurrentHashMap: Implementation Differences between JDK 1.7 and JDK 1.8
Sohu Tech Products
Sohu Tech Products
Apr 22, 2020 · Backend Development

Understanding ThreadLocal in Java: Implementation, Memory‑Leak Risks, and Practical Use Cases

This article explains Java's ThreadLocal mechanism, shows how it provides thread‑confinement without synchronization, analyses its source code—including hash generation, internal ThreadLocalMap structure, set/get operations and resize logic—highlights potential memory‑leak pitfalls, and lists common application scenarios.

ThreadLocalbackend-developmentjava
0 likes · 16 min read
Understanding ThreadLocal in Java: Implementation, Memory‑Leak Risks, and Practical Use Cases
Watermelon Video Tech Team
Watermelon Video Tech Team
Apr 7, 2020 · Mobile Development

Investigation and Fix of Android Native Crash in CookieManager.getCookie Caused by Thread‑Unsafe GURL Initialization

An in‑depth analysis of a long‑standing native crash on Android caused by thread‑unsafe initialization of GURL during CookieManager.getCookie calls, detailing stack traces, investigation steps, source code examination, and a lightweight application‑level synchronization fix that eliminated the issue in production.

AndroidCookieManagerGURL
0 likes · 10 min read
Investigation and Fix of Android Native Crash in CookieManager.getCookie Caused by Thread‑Unsafe GURL Initialization
Java Captain
Java Captain
Mar 28, 2020 · Fundamentals

Understanding the Impact of Print Statements, sleep, and Integer on Java Thread Safety

This article explores how adding print statements, using Thread.sleep, and employing Integer objects affect thread safety in Java, illustrating why a non‑volatile flag can cause infinite loops, how synchronized I/O and sleep influence memory visibility, and why seemingly unrelated changes sometimes make the program terminate.

JITjavathread safety
0 likes · 15 min read
Understanding the Impact of Print Statements, sleep, and Integer on Java Thread Safety
Architecture Digest
Architecture Digest
Mar 14, 2020 · Fundamentals

Understanding the Java Memory Model (JMM) and Its Concurrency Rules

This article explains the Java Memory Model, describing how main memory and thread‑local working memory interact, the eight primitive actions defined by the JVM, the special semantics of volatile, long and double variables, and how these concepts underpin atomicity, visibility and the happens‑before principle in concurrent Java programs.

Happens-beforeJMMMemory Model
0 likes · 23 min read
Understanding the Java Memory Model (JMM) and Its Concurrency Rules
FunTester
FunTester
Feb 26, 2020 · Fundamentals

Why Thread‑Safe Collections Still Fail with Non‑Thread‑Safe Objects in Java

Through a series of Java demos, this article examines how storing non‑thread‑safe objects inside thread‑safe collections like ConcurrentHashMap or CopyOnWriteArrayList can still cause concurrency bugs, explains the underlying remove() implementation, and shows how switching to a thread‑safe Vector resolves the issue.

CollectionsConcurrentHashMapCopyOnWriteArrayList
0 likes · 8 min read
Why Thread‑Safe Collections Still Fail with Non‑Thread‑Safe Objects in Java
FunTester
FunTester
Feb 24, 2020 · Backend Development

Achieving Thread‑Safe Java Performance Tests Without Locks

This article explains why traditional locking harms Java performance‑testing throughput, introduces lock‑free alternatives such as CAS and ThreadLocal, and provides a complete Java demo that shows how each thread can hold its own object to eliminate contention and boost speed.

Performance TestingThreadLocalconcurrency
0 likes · 5 min read
Achieving Thread‑Safe Java Performance Tests Without Locks
FunTester
FunTester
Feb 17, 2020 · Fundamentals

Mastering Thread‑Safe Objects in Java: From Synchronized Collections to Atomic Variables

This article explains how Java threads share objects, why immutable objects are safest, how to make mutable collections thread‑safe using synchronized wrappers or concurrent classes, handles non‑thread‑safe types like SimpleDateFormat, and demonstrates race‑condition fixes with synchronized blocks and AtomicInteger.

AtomicIntegerCollectionsSynchronization
0 likes · 10 min read
Mastering Thread‑Safe Objects in Java: From Synchronized Collections to Atomic Variables
Architect's Tech Stack
Architect's Tech Stack
Feb 14, 2020 · Backend Development

Understanding ThreadLocal Variables in Java: Implementation, Memory Leak Issues, and Use Cases

This article explains what ThreadLocal variables are, how they are implemented in Java using a per‑thread ThreadLocalMap, discusses potential memory‑leak pitfalls caused by weak keys, and demonstrates common usage scenarios such as per‑thread session storage and making non‑thread‑safe classes like SimpleDateFormat thread‑safe.

ThreadLocalmemory leakthread safety
0 likes · 7 min read
Understanding ThreadLocal Variables in Java: Implementation, Memory Leak Issues, and Use Cases
FunTester
FunTester
Jan 26, 2020 · Backend Development

Common Concurrency Bugs in Backend Java Development and Their Solutions

Although developers often overlook high‑concurrency scenarios, this article highlights two typical backend Java concurrency bugs—shared request state in singleton beans and improper lazy initialization—explains their pitfalls, and demonstrates correct thread‑safe patterns such as double‑checked locking and proper singleton design.

Singletonconcurrencyjava
0 likes · 5 min read
Common Concurrency Bugs in Backend Java Development and Their Solutions
Architecture Digest
Architecture Digest
Jan 4, 2020 · Backend Development

Java Concurrency: Thread Safety, Visibility, Atomicity, and Lock Mechanisms

This article provides a comprehensive overview of Java concurrency concepts, covering thread‑safety issues, variable visibility, atomic operations, the use of synchronized, volatile, ReentrantLock, ReadWriteLock, CountDownLatch, and other AQS‑based synchronizers, with code examples illustrating each mechanism.

AQSLocksSynchronization
0 likes · 34 min read
Java Concurrency: Thread Safety, Visibility, Atomicity, and Lock Mechanisms
Senior Brother's Insights
Senior Brother's Insights
Nov 4, 2019 · Fundamentals

Why Understanding Java Memory Model Boosts Your Code Efficiency

This article explains the hardware memory architecture, the role of caches, and how the Java Memory Model abstracts thread interaction with main and working memory, detailing the eight fundamental JMM operations, their ordering rules, and special considerations for long and double types to help developers write correct, high‑performance concurrent Java code.

CacheJVMMemory Model
0 likes · 11 min read
Why Understanding Java Memory Model Boosts Your Code Efficiency
Java Architecture Diary
Java Architecture Diary
Nov 2, 2019 · Backend Development

Why SimpleDateFormat Is Not Thread‑Safe and How to Fix It Efficiently

This article explains why Java's SimpleDateFormat is not thread‑safe, demonstrates the resulting concurrency errors, and presents four practical solutions—including per‑call instantiation, ThreadLocal, Apache FastDateFormat, and Java 8's Instant with DateTimeFormatter—along with JMH benchmark results comparing their performance across JDK 8 and JDK 11.

SimpleDateFormatThreadLocaldateformat
0 likes · 7 min read
Why SimpleDateFormat Is Not Thread‑Safe and How to Fix It Efficiently
FunTester
FunTester
Oct 27, 2019 · Operations

How to Load Test Multi‑Row Single Updates with Thread‑Safe Queues in Java

This article explains how to perform load testing for scenarios where each row can be updated only once, using a thread‑safe queue to supply unique parameters to concurrent threads, and provides complete Java code examples for both a global queue and per‑thread queues.

Load TestingPerformance TestingQueue
0 likes · 6 min read
How to Load Test Multi‑Row Single Updates with Thread‑Safe Queues in Java
Selected Java Interview Questions
Selected Java Interview Questions
Oct 20, 2019 · Fundamentals

Java Singleton Pattern Implementations and Variants

This article explains four main categories of Java singleton implementations—eager (hungry), lazy (lazy), holder, and enum—detailing their basic forms, variations, thread‑safety characteristics, performance trade‑offs, and code examples, while also discussing pitfalls such as reflection and serialization.

Singletondesign patternenum
0 likes · 10 min read
Java Singleton Pattern Implementations and Variants
Programmer DD
Programmer DD
Sep 5, 2019 · Fundamentals

Understanding ThreadLocal: Solving Thread Safety Issues in Java

This article explains thread safety problems, demonstrates how unsynchronized access to shared variables can produce incorrect results, and shows how Java's ThreadLocal and InheritableThreadLocal classes provide thread‑local storage to avoid concurrency bugs, including implementation details and usage examples.

InheritableThreadLocalThreadLocaljava
0 likes · 9 min read
Understanding ThreadLocal: Solving Thread Safety Issues in Java
Programmer DD
Programmer DD
Aug 24, 2019 · Fundamentals

Why Java Strings Are Immutable and How It Boosts Performance

This article explains the concept of Java String immutability, illustrates how references work with examples and diagrams, and discusses the benefits such as string pool reuse, hashcode caching, thread safety, and security that improve memory efficiency and application performance.

Stringimmutabilityjava
0 likes · 8 min read
Why Java Strings Are Immutable and How It Boosts Performance
FunTester
FunTester
Jul 22, 2019 · Fundamentals

Why i++ Is Not Thread‑Safe: A Hands‑On Demo with vmlens

This article demonstrates how the non‑atomic i++ operation can cause race conditions in Java by using the vmlens tool to visualize thread interleavings, providing sample test code, Maven configuration, and an analysis of the resulting report.

concurrencyjavamultithreading
0 likes · 6 min read
Why i++ Is Not Thread‑Safe: A Hands‑On Demo with vmlens
FunTester
FunTester
Jul 22, 2019 · Backend Development

Thread Safety Issues When Combining Thread‑Safe Methods: A ConcurrentHashMap Example

Even when using thread‑safe classes like Java's ConcurrentHashMap, combining multiple thread‑safe methods into a single operation can still cause race conditions, as demonstrated by a test where two threads concurrently execute get‑and‑put logic, leading to an unexpected map value and a failed assertion.

ConcurrentHashMapconcurrencyjava
0 likes · 3 min read
Thread Safety Issues When Combining Thread‑Safe Methods: A ConcurrentHashMap Example
FunTester
FunTester
Jul 19, 2019 · Fundamentals

Why i++ Is Not Thread‑Safe: A Hands‑On Demo with vmlens

This article demonstrates how the non‑atomic i++ operation can cause race conditions in Java, using a simple multithreaded test and the vmlens tool to visualize the conflicting accesses and explain the underlying thread‑safety issue.

javamavenmultithreading
0 likes · 7 min read
Why i++ Is Not Thread‑Safe: A Hands‑On Demo with vmlens
FunTester
FunTester
Jul 16, 2019 · Fundamentals

Why Incrementing a Counter Isn’t Thread‑Safe in Java: A Hands‑On Demo

This article explains atomicity, thread safety, and thread‑unsafe behavior in Java, demonstrates a simple class with a volatile counter, runs two concurrent threads that increment it, shows the non‑atomic nature of i++, and analyzes why the final value may remain 1.

atomicityconcurrencyjava
0 likes · 4 min read
Why Incrementing a Counter Isn’t Thread‑Safe in Java: A Hands‑On Demo
FunTester
FunTester
Jul 14, 2019 · Fundamentals

Why a Simple Increment Fails in Multithreaded Java: A Concurrency Demo

This article explains atomicity, thread safety, and race conditions in Java by walking through a concrete example where multiple threads increment a shared volatile variable, showing why the non‑atomic i++ operation leads to inconsistent results.

atomicityconcurrencyexample
0 likes · 4 min read
Why a Simple Increment Fails in Multithreaded Java: A Concurrency Demo
Java Backend Technology
Java Backend Technology
Jun 27, 2019 · Backend Development

Is Your Java Singleton Really a Singleton? Thread, Reflection & Serialization Pitfalls

This article examines various Java singleton implementations—eager, lazy, double‑checked locking, static inner class, enum, and Kotlin object—analyzing their thread safety, reflection and serialization vulnerabilities, and shows how to harden them using volatile, constructor guards, and readResolve.

ReflectionSingletondesign pattern
0 likes · 12 min read
Is Your Java Singleton Really a Singleton? Thread, Reflection & Serialization Pitfalls
dbaplus Community
dbaplus Community
Jun 16, 2019 · Fundamentals

Understanding Thread Safety: From ThreadLocal to Locks and CAS

This article explains why thread safety concerns memory rather than threads, compares stack‑local and heap‑shared data, introduces ThreadLocal for per‑thread isolation, and covers mutual‑exclusion locks, optimistic CAS, and their appropriate use cases in concurrent programming.

CASJava concurrencyLocks
0 likes · 15 min read
Understanding Thread Safety: From ThreadLocal to Locks and CAS
Programmer DD
Programmer DD
May 12, 2019 · Backend Development

Why SimpleDateFormat Breaks in Multithreaded Java and How to Fix It

This article explains why the classic Java SimpleDateFormat class is not thread‑safe, demonstrates the problems caused by using a static instance in concurrent code, and presents four practical solutions—including creating new instances, synchronizing, using ThreadLocal, and switching to the immutable DateTimeFormatter.

DateTimeFormatterSimpleDateFormatThreadLocal
0 likes · 8 min read
Why SimpleDateFormat Breaks in Multithreaded Java and How to Fix It
NetEase Game Operations Platform
NetEase Game Operations Platform
Mar 23, 2019 · Backend Development

Implementing a Redis‑Based Distributed Lock to Ensure Data Consistency in a CMDB System

This article analyzes data‑inconsistency problems caused by concurrent multithreaded updates in a CMDB system and presents a step‑by‑step exploration of synchronization solutions, ultimately implementing a robust Redis‑backed distributed lock in Python to guarantee atomic reads and writes while handling edge cases such as crashes and lock expiration.

CMDBData ConsistencyPython
0 likes · 17 min read
Implementing a Redis‑Based Distributed Lock to Ensure Data Consistency in a CMDB System
Java Backend Technology
Java Backend Technology
Mar 19, 2019 · Backend Development

Why SimpleDateFormat Is Not Thread‑Safe and How to Fix It in Java

This article explains why Java's SimpleDateFormat is not thread‑safe, demonstrates the problems caused by using a static instance in multithreaded code, and presents four practical solutions—including synchronized blocks, ThreadLocal, and the modern DateTimeFormatter—to ensure correct date handling.

DateTimeFormatterSimpleDateFormatThreadLocal
0 likes · 5 min read
Why SimpleDateFormat Is Not Thread‑Safe and How to Fix It in Java
Big Data Technology & Architecture
Big Data Technology & Architecture
Feb 16, 2019 · Fundamentals

Understanding ConcurrentSkipListSet in Java: Overview, Principles, API, and Example

This article explains the thread‑safe, ordered Java collection ConcurrentSkipListSet, compares it with TreeSet, describes its skip‑list based internal structure, lists its full API, and provides a multithreaded example demonstrating correct concurrent usage versus the failure of TreeSet.

Concurrent CollectionsConcurrentSkipListSetData Structures
0 likes · 8 min read
Understanding ConcurrentSkipListSet in Java: Overview, Principles, API, and Example
Full-Stack Internet Architecture
Full-Stack Internet Architecture
Oct 17, 2018 · Backend Development

Understanding CopyOnWriteArrayList in Java: Implementation, Principles, and Comparison with ArrayList

CopyOnWriteArrayList is a thread‑safe variant of ArrayList that achieves read‑write separation by copying the underlying array on each mutative operation, using a ReentrantLock for writes, making it ideal for read‑heavy, write‑light scenarios, and it differs from ArrayList in safety, performance, and concurrency behavior.

CopyOnWriteArrayListData Structuresconcurrency
0 likes · 5 min read
Understanding CopyOnWriteArrayList in Java: Implementation, Principles, and Comparison with ArrayList
Java Captain
Java Captain
Sep 12, 2018 · Fundamentals

Understanding Processes, Threads, Multithreading, and Thread Safety in Java

This article explains the fundamentals of processes, threads, and multithreading in Java, illustrates common thread‑safety problems with example code, and demonstrates how to achieve safe concurrent execution using synchronized blocks and the Lock API, including tryLock with timeout.

Lockjavamultithreading
0 likes · 11 min read
Understanding Processes, Threads, Multithreading, and Thread Safety in Java
Xianyu Technology
Xianyu Technology
Aug 28, 2018 · Mobile Development

Understanding Flutter Platform Channel Working Principles

The article explains Flutter’s platform channels—BasicMessageChannel, MethodChannel, and EventChannel—detailing their components (name, messenger, codec), how messages are encoded, decoded, and routed via BinaryMessenger, the various codecs and handlers, and considerations for thread safety, large data transfer, and practical usage.

FlutterMobile DevelopmentPlatform Channel
0 likes · 14 min read
Understanding Flutter Platform Channel Working Principles
Senior Brother's Insights
Senior Brother's Insights
Aug 23, 2018 · Fundamentals

Mastering the Singleton Pattern in Java: Eager, Lazy, Double‑Check, and More

Explore the GOF 23 design patterns with a deep dive into the Singleton pattern, covering its purpose, characteristics, comparison to static classes, and multiple Java implementations—including eager, lazy, double‑checked locking, volatile, static inner class, and enum approaches—plus Spring’s real‑world usage.

Design PatternsSingletonenum
0 likes · 12 min read
Mastering the Singleton Pattern in Java: Eager, Lazy, Double‑Check, and More
Programmer DD
Programmer DD
Jul 18, 2018 · Backend Development

How Does Java’s ConcurrentLinkedQueue Achieve Lock‑Free Thread Safety?

This article explains the lock‑free design of Java's ConcurrentLinkedQueue, detailing its core invariants, the internal Node structure, and step‑by‑step analyses of the offer and poll methods with code snippets and visual illustrations to demystify its CAS‑based concurrency mechanisms.

CASConcurrentLinkedQueuejava
0 likes · 13 min read
How Does Java’s ConcurrentLinkedQueue Achieve Lock‑Free Thread Safety?
Programmer DD
Programmer DD
Jun 21, 2018 · Fundamentals

Master Java Interview Essentials: 8 Classic Questions Explained

This article breaks down eight core Java interview questions, offering deep analysis of platform fundamentals, exception handling, reflection, I/O, concurrency, and object‑oriented design to help candidates demonstrate solid understanding beyond superficial answers.

Core ConceptsException HandlingReflection
0 likes · 12 min read
Master Java Interview Essentials: 8 Classic Questions Explained