Tagged articles
thread-safety
19 articles · Page 1 of 1
The article explains that Java makes the String class final to ensure security, improve performance through string pooling and hash‑code caching, provide inherent thread‑safety, and maintain consistent behavior by preventing subclassing, illustrating each benefit with clear examples.
FinalJavaString
0 likes · 4 min read

This article explores common pitfalls in Java date handling—such as non‑thread‑safe formatting and daylight‑saving‑time errors—and presents robust solutions using ThreadLocal, the Java 8 Date/Time API, zone‑aware calculations, caching, and global interceptor patterns to ensure correct, high‑performance time processing in backend systems.
BackendJava 8date-formatting
0 likes · 7 min read

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.
ConcurrencyJavaSynchronization
0 likes · 15 min read

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

This article describes a Java performance‑testing script that uses concurrent user initialization, explains how overlooking atomicity in thread‑safe classes caused some users to miss initialization, and presents three practical solutions such as improving stop logic, tracking completed users, and using concurrent collections.
Multithreadingatomicityperformance-testing
0 likes · 7 min read

This article explains how LinkedBlockingQueue, normally thread‑safe, can enter an infinite loop when its stream traversal is used under JDK 8 with concurrent remove() calls, analyzes the root cause in the tryAdvance method, and shows how the bug was fixed in later JDK versions.
JDK8JavaLinkedBlockingQueue
0 likes · 15 min read

This article examines the internal workings of Java's CopyOnWriteArrayList, explains why its weak consistency still necessitates read‑write locks in read‑heavy scenarios, and compares exclusive locks with read‑write locks to achieve strong data consistency without sacrificing performance.
CopyOnWriteArrayListJavaReadWriteLock
0 likes · 11 min read

This article explains the Java synchronized keyword in depth, covering class-level and object-level locks, reentrancy, interruption behavior, timeout limitations, and performance tips, while providing numerous runnable code demos and practical conclusions for safe multithreaded programming.
JavaMultithreadinglocking
0 likes · 17 min read

This article examines common sources of performance‑testing errors—including hidden locking‑resource issues, inadequate local machine configuration, inefficient regex‑based data extraction, costly exception handling, and unsynchronized thread termination—while offering practical Java‑centric mitigation strategies.
error-analysisload-testingperformance-testing
0 likes · 7 min read

This article explains Java's synchronized keyword, demonstrating both synchronized code block locks and method locks with complete code examples, analyzing execution results, and discussing memory-level locking, thread safety, performance drawbacks, and best practices for using synchronized in concurrent programming.
Code ExampleJavaSynchronization
0 likes · 8 min read

This article explains how the volatile keyword ensures visibility of shared variables across threads, illustrates its behavior with examples and code, discusses its limitations regarding atomicity, and presents solutions using synchronized blocks or atomic classes for proper thread synchronization in Java.
ConcurrencyJavaSynchronization
0 likes · 8 min read

This article explains why a static SimpleDateFormat instance is not thread‑safe, demonstrates the issue with concurrent parsing, and provides a ThreadLocal‑based solution with complete Java code examples and performance observations.
SimpleDateFormatdate-formattingthread-safety
0 likes · 10 min read

This article explores a JDK 8 bug in ConcurrentHashMap’s computeIfAbsent method that can cause an infinite loop, explains how the issue was discovered, reproduces it with test code, analyzes the root cause, and shows the fix introduced in JDK 9.
ConcurrentHashMapJDKbug
0 likes · 16 min read

This article explains why Java's SimpleDateFormat is not thread‑safe, demonstrates the problem with multithreaded examples, and presents two robust solutions—using ThreadLocal or the Java 8 immutable date‑time API—to ensure correct date formatting in concurrent environments.
SimpleDateFormatdate-time APIjava-8
0 likes · 6 min read

This article explains atomicity, thread safety, and race conditions in Java by showing how a volatile counter increment can produce nondeterministic results when accessed concurrently, complete with sample code and console output analysis.
ConcurrencyMultithreadingatomicity
0 likes · 4 min read

The article explains why using the synchronized keyword together with Spring's @Transactional annotation can lead to lost updates when many threads increment a database field, analyzes the underlying transaction‑proxy interaction, and presents a refactored solution that moves the lock to a separate service to ensure correct results.
ConcurrencyJavaSpring
0 likes · 7 min read

This article explains Java's final keyword, covering its use with classes, methods, and variables, demonstrates how to declare final members, shows code examples of final variables, methods, and classes, and discusses the performance, thread‑safety, and immutability benefits of using final in Java applications.
Finalkeywordthread-safety
0 likes · 7 min read

This article explains how to build a Java event‑notification system using the observer pattern, highlights typical mistakes such as concurrent modification and deadlocks, and presents several thread‑safe implementations ranging from synchronized blocks to CopyOnWriteArraySet and atomic primitives.
ConcurrencyEvent NotificationObserver Pattern
0 likes · 10 min read

The article explains the concept of immutable objects in object‑oriented programming, uses Java’s String and Date classes as examples, lists benefits such as thread safety, reduced coupling and side‑effects, and discusses counter‑arguments and practical considerations for adopting immutability.
DesignJavaimmutability
0 likes · 8 min read
