Tagged articles

singleton

178 articles · Page 2 of 2
Full-Stack Internet Architecture
Full-Stack Internet Architecture
Oct 27, 2021 · Fundamentals

Common Design Patterns in Daily Development: Strategy, Chain of Responsibility, Template Method, Observer, Factory, and Singleton

This article introduces several classic design patterns—Strategy, Chain of Responsibility, Template Method, Observer, Factory, and Singleton—explaining their business scenarios, core definitions, Java implementations, and how to apply them in real-world projects to improve code maintainability and extensibility.

Chain of ResponsibilityDesign Patternsfactory
0 likes · 27 min read
Common Design Patterns in Daily Development: Strategy, Chain of Responsibility, Template Method, Observer, Factory, and Singleton
360 Zhihui Cloud Developer
360 Zhihui Cloud Developer
Oct 21, 2021 · Backend Development

Mastering sync.Once in Go: Thread‑Safe Singleton Patterns Explained

This article explains Go's sync.Once primitive, compares it with init, details various singleton implementations—including lazy, eager, and double‑checked locking—and provides practical code examples and a deep dive into its source implementation for thread‑safe one‑time initialization.

GoLazy InitializationThread Safety
0 likes · 7 min read
Mastering sync.Once in Go: Thread‑Safe Singleton Patterns Explained
Java Interview Crash Guide
Java Interview Crash Guide
Oct 20, 2021 · Backend Development

How Spring Implements Classic Design Patterns: From Simple Factory to Template Method

This article explains how Spring’s core container uses classic design patterns—Simple Factory via BeanFactory, Factory Method with FactoryBean, Singleton, Adapter, Decorator, Proxy, Observer, Strategy, and Template Method—illustrated with code snippets and diagrams to show their implementation and purpose within the framework.

BeanFactoryFactory MethodSpring
0 likes · 15 min read
How Spring Implements Classic Design Patterns: From Simple Factory to Template Method
Architecture Digest
Architecture Digest
Oct 5, 2021 · Backend Development

Understanding Simple Factory, Factory Method, Singleton, Adapter, Decorator, Observer, Strategy, and Template Method Patterns in Spring

This article explains how Spring implements classic design patterns—including Simple Factory via BeanFactory, Factory Method with FactoryBean, Singleton with double‑checked locking, Adapter through HandlerAdapter, Decorator via Wrapper classes, Observer in its event model, Strategy via the Resource interface, and Template Method in JdbcTemplate—providing clear examples and code snippets for each.

Factory MethodSpringbackend development
0 likes · 13 min read
Understanding Simple Factory, Factory Method, Singleton, Adapter, Decorator, Observer, Strategy, and Template Method Patterns in Spring
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.

ControllerThread Safetyconcurrency
0 likes · 6 min read
Why Spring MVC Controllers Are Singleton and How to Ensure Thread Safety
Top Architect
Top Architect
Jul 23, 2021 · Backend Development

Design Patterns in the Spring Framework: A Comprehensive Overview

This article provides a detailed overview of how the Spring framework implements classic design patterns—including Simple Factory, Factory Method, Singleton, Adapter, Decorator, Proxy, Observer, Strategy, and Template Method—illustrated with code snippets and explanations of their roles in Spring's dependency injection and bean lifecycle management.

Design PatternsSpringdependency injection
0 likes · 14 min read
Design Patterns in the Spring Framework: A Comprehensive Overview
Java Backend Technology
Java Backend Technology
Jul 22, 2021 · Fundamentals

Master Java Enums: From Basics to Advanced Design Patterns

This article explains Java enums, their advantages over constants, demonstrates custom methods, comparisons, switch usage, advanced features like EnumSet, EnumMap, JSON serialization, and shows how enums can implement design patterns such as Singleton and Strategy with complete code examples.

Design PatternsEnumEnumMap
0 likes · 14 min read
Master Java Enums: From Basics to Advanced Design Patterns
Java High-Performance Architecture
Java High-Performance Architecture
Jun 7, 2021 · Fundamentals

23 Essential Design Patterns Explained with Fun Real‑World Analogies

This article humorously illustrates 23 classic software design patterns—such as Factory Method, Builder, Abstract Factory, Prototype, Singleton, Adapter, Bridge, Composite, Decorator, Facade, Flyweight, Proxy, Chain of Responsibility, Command, Interpreter, Iterator, Mediator, Memento, Observer, State, Strategy, Template Method, and Visitor—by mapping each to everyday relationship scenarios.

BuilderDesign PatternsFactory Method
0 likes · 18 min read
23 Essential Design Patterns Explained with Fun Real‑World Analogies
Programmer DD
Programmer DD
May 11, 2021 · Fundamentals

Mastering Java Constructors and Design Patterns: From Implicit to Singleton

This article provides a comprehensive guide to Java object creation, covering implicit, no‑argument, and argument constructors, initialization blocks, static initialization, default value guarantees, visibility rules, garbage collection, finalizers, and common construction patterns such as singleton, helper, factory, and dependency injection.

ConstructorsInitializationdependency-injection
0 likes · 17 min read
Mastering Java Constructors and Design Patterns: From Implicit to Singleton
Sohu Tech Products
Sohu Tech Products
May 5, 2021 · Fundamentals

Common Design Patterns in Kotlin: Singleton, Factory, Builder, Prototype, Decorator, Strategy, Template Method, and Observer

This article introduces several classic design patterns—Singleton, Factory, Builder, Prototype, Decorator, Strategy, Template Method, and Observer—showing how they can be implemented concisely in Kotlin with code examples, while also explaining the underlying language features such as object declarations, companion objects, delegation, lazy initialization, and higher‑order functions.

BuilderDesign PatternsKotlin
0 likes · 23 min read
Common Design Patterns in Kotlin: Singleton, Factory, Builder, Prototype, Decorator, Strategy, Template Method, and Observer
Intelligent Backend & Architecture
Intelligent Backend & Architecture
May 5, 2021 · Fundamentals

Master Creational Design Patterns: Singleton, Prototype, Factory, Abstract Factory & Builder Explained

This comprehensive guide explains creational design patterns—including Singleton, Prototype, Factory Method, Abstract Factory, and Builder—detailing their definitions, characteristics, structures, Java implementations, code examples, and typical application scenarios for reducing coupling and improving flexibility in software development.

Abstract FactoryBuilderFactory Method
0 likes · 32 min read
Master Creational Design Patterns: Singleton, Prototype, Factory, Abstract Factory & Builder Explained
Architecture Digest
Architecture Digest
Mar 20, 2021 · Fundamentals

A Humorous Overview of 23 Classic Software Design Patterns

This article presents a playful yet informative walkthrough of twenty‑three classic software design patterns—Factory Method, Builder, Abstract Factory, Prototype, Singleton, Adapter, Bridge, Composite, Decorator, Facade, Flyweight, Proxy, Chain of Responsibility, Command, Interpreter, Iterator, Mediator, Memento, Observer, State, Strategy, Template Method and Visitor—using everyday analogies to illustrate their intent and structure.

BuilderDesign PatternsFactory Method
0 likes · 18 min read
A Humorous Overview of 23 Classic Software Design Patterns
Java Captain
Java Captain
Mar 19, 2021 · Fundamentals

A Humorous Guide to 23 Software Design Patterns Using Dating Analogies

This article humorously explains 23 classic software design patterns—such as Factory Method, Builder, Abstract Factory, Prototype, Singleton, Adapter, Bridge, Composite, Decorator, Facade, Flyweight, Proxy, Chain of Responsibility, Command, Interpreter, Iterator, Mediator, Memento, Observer, State, Strategy, Template Method, and Visitor—by comparing each pattern to everyday dating scenarios.

BuilderDesign PatternsFactory Method
0 likes · 18 min read
A Humorous Guide to 23 Software Design Patterns Using Dating Analogies
Top Architect
Top Architect
Mar 3, 2021 · Backend Development

How Spring Solves Circular Dependencies and the Underlying Essence

This article explains Spring's approach to resolving circular dependencies in singleton beans using a three‑level cache, contrasts it with prototype bean limitations, provides a simplified implementation example, and draws an analogy to the classic two‑sum algorithm to illustrate the core concept.

Circular DependencyDesign PatternsSpring
0 likes · 9 min read
How Spring Solves Circular Dependencies and the Underlying Essence
Selected Java Interview Questions
Selected Java Interview Questions
Feb 21, 2021 · Fundamentals

Understanding Double-Checked Locking Singleton Pattern in Java

This article explains the double-checked locking implementation of the Singleton pattern in Java, detailing why two null checks are necessary, the role of the volatile keyword in preventing instruction reordering and ensuring visibility across threads, and provides a complete example code.

Volatileconcurrencydouble-checked locking
0 likes · 5 min read
Understanding Double-Checked Locking Singleton Pattern in Java
Java Captain
Java Captain
Feb 20, 2021 · Backend Development

Spring Framework Design Patterns: Summary and Implementation Details

This article provides a comprehensive overview of the design patterns used in the Spring framework—including Simple Factory, Factory Method, Singleton, Adapter, Decorator, Proxy, Observer, Strategy, and Template Method—explaining their implementation, underlying principles, and practical significance with code examples.

BeanFactoryDesign PatternsFactory Method
0 likes · 15 min read
Spring Framework Design Patterns: Summary and Implementation Details
Architect's Tech Stack
Architect's Tech Stack
Feb 18, 2021 · Backend Development

Summary of Design Patterns Used in the Spring Framework

This article provides a comprehensive overview of how Spring implements classic design patterns such as Simple Factory, Factory Method, Singleton, Adapter, Decorator, Proxy, Observer, and Template Method, explaining their implementation details, underlying principles, and practical code examples within the Spring container.

Design PatternsSpringdependency injection
0 likes · 15 min read
Summary of Design Patterns Used in the Spring Framework
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.

Design PatternEnumThread Safety
0 likes · 11 min read
Comprehensive Guide to the Singleton Pattern in Java: Implementations, Pitfalls, and the Secure Enum Solution
Liangxu Linux
Liangxu Linux
Feb 6, 2021 · Operations

How to Make a Bash Script Run Only Once: Lock Files and flock Explained

This guide shows how to prevent a Bash script from being executed multiple times by detecting existing instances, using lock files with process checks, and employing the flock command for reliable atomic locking, complete with practical code examples and pitfalls to avoid.

Operationsbashflock
0 likes · 8 min read
How to Make a Bash Script Run Only Once: Lock Files and flock Explained
Programmer DD
Programmer DD
Feb 6, 2021 · Fundamentals

Master 22 Design Patterns Through Hilarious Real‑World Analogies

This article humorously explains 22 classic software design patterns—such as Factory Method, Builder, Abstract Factory, Prototype, Singleton, Adapter, Bridge, Composite, Decorator, Facade, Flyweight, Proxy, Chain of Responsibility, Command, Interpreter, Iterator, Mediator, Memento, Observer, State, Strategy, Template Method, and Visitor—by likening each to everyday dating and food scenarios, making the concepts easy to grasp.

BuilderFactory MethodSoftware Engineering
0 likes · 18 min read
Master 22 Design Patterns Through Hilarious Real‑World Analogies
Java Architect Essentials
Java Architect Essentials
Jan 17, 2021 · Backend Development

Java Parking System Implementation Example

This article presents a complete Java-based parking system example, detailing functional requirements for users and administrators, and providing full source code for client interaction, entity definitions, service interfaces, and their implementations, illustrating backend development concepts such as singleton patterns, service layers, and basic CRUD operations.

Code ExampleService Layerbackend development
0 likes · 17 min read
Java Parking System Implementation Example
Full-Stack Internet Architecture
Full-Stack Internet Architecture
Jan 8, 2021 · Backend Development

Deep Dive into Java HashMap, ConcurrentHashMap, JMM, and Concurrency Fundamentals

This article provides a comprehensive overview of Java's HashMap and ConcurrentHashMap implementations, explains core concurrency concepts such as thread states, the differences between concurrency and parallelism, memory models, volatile semantics, singleton patterns, thread pools, ThreadLocal, CAS, and the AQS framework.

HashMapThreadPoolconcurrency
0 likes · 31 min read
Deep Dive into Java HashMap, ConcurrentHashMap, JMM, and Concurrency Fundamentals
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.

BeanScopeSpring
0 likes · 11 min read
Understanding Thread Safety of Spring Beans: Singleton vs Prototype Scope
Nullbody Notes
Nullbody Notes
Nov 19, 2020 · Fundamentals

Understanding the Singleton Pattern in Go: Eager vs Lazy Implementations

The article explains Go's singleton pattern, detailing eager (init) and lazy implementations using sync.Mutex and sync.Once, provides full code examples, demonstrates that each accessor returns the same instance, and discusses trade‑offs between memory usage and performance.

Design PatternGoconcurrency
0 likes · 5 min read
Understanding the Singleton Pattern in Go: Eager vs Lazy Implementations
php Courses
php Courses
Nov 2, 2020 · Backend Development

Implementing a Redis Multi-Database Singleton Wrapper in ThinkPHP

This guide demonstrates how to set up a Redis multi-database singleton wrapper in a ThinkPHP project, covering prerequisite installation, configuration of connection parameters, creation of a custom Redis class with static instance management, and example usage of Redis commands across different databases.

PHPRedisThinkPHP
0 likes · 3 min read
Implementing a Redis Multi-Database Singleton Wrapper in ThinkPHP
Laravel Tech Community
Laravel Tech Community
Sep 1, 2020 · Fundamentals

PHP Design Patterns: Singleton, Factory, Registry, Adapter, and Observer

This article introduces common PHP design patterns—including Singleton, Factory, Registry, Adapter, and Observer—explaining their purpose, structure, typical use cases, and providing complete code examples for each pattern to illustrate how they can be implemented in object‑oriented applications.

Design PatternsPHPadapter
0 likes · 7 min read
PHP Design Patterns: Singleton, Factory, Registry, Adapter, and Observer
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 ScopeControllerSpring
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 ScopeControllerSpring
0 likes · 6 min read
Understanding Spring Controller Bean Scope: Singleton vs Prototype and Thread Safety
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.

BeanControllerScope
0 likes · 5 min read
Understanding Spring Controller Scope and Thread Safety
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.

Design PatternEnumLazy Initialization
0 likes · 6 min read
Java Singleton Pattern: Lazy, Eager, Static Inner Class, Enum, and Double-Checked Locking
Java Backend Technology
Java Backend Technology
Mar 26, 2020 · Fundamentals

Mastering Java Enums: From Basics to Advanced Design Patterns

This article explains what Java enums are, why they are useful, how to define simple and custom enum types, compare them safely, use them in switch statements, enrich them with fields, methods and constructors, and apply them in advanced scenarios such as EnumSet, EnumMap, Singleton and Strategy patterns, as well as Java 8 stream APIs and JSON serialization.

EnumMapEnumSetEnums
0 likes · 17 min read
Mastering Java Enums: From Basics to Advanced Design Patterns
ITFLY8 Architecture Home
ITFLY8 Architecture Home
Mar 19, 2020 · Backend Development

How Spring Implements 9 Core Design Patterns – From Simple Factory to Template Method

This article explains how Spring applies nine classic design patterns—including Simple Factory, Factory Method, Singleton, Adapter, Decorator, Proxy, Observer, Strategy, and Template Method—detailing their implementation approaches, underlying principles, and the benefits they bring to Spring's IoC container and AOP mechanisms.

Factory MethodSpringbackend development
0 likes · 18 min read
How Spring Implements 9 Core Design Patterns – From Simple Factory to Template Method
FunTester
FunTester
Feb 15, 2020 · Backend Development

Understanding Double-Checked Locking Singleton Pattern in Java

This article explains the double‑checked locking design pattern for thread‑safe singletons in Java, demonstrates its performance drawbacks, and presents alternative implementations such as early initialization, init‑on‑demand holder, and enum‑based singletons, highlighting their advantages and limitations.

Design Patternconcurrencydouble-checked locking
0 likes · 6 min read
Understanding Double-Checked Locking Singleton Pattern in Java
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.

Lazy InitializationThread Safetyconcurrency
0 likes · 5 min read
Common Concurrency Bugs in Backend Java Development and Their Solutions
Architecture Digest
Architecture Digest
Jan 11, 2020 · Backend Development

Design Patterns Used in MyBatis Source Code

This article examines how MyBatis implements numerous classic design patterns—including Builder, Factory, Singleton, Proxy, Composite, Template Method, Adapter, Decorator, and Iterator—through its source code, explaining each pattern's role, related classes, and code examples to deepen developers' understanding of backend architecture.

BuilderIteratorMyBatis
0 likes · 17 min read
Design Patterns Used in MyBatis Source Code
Selected Java Interview Questions
Selected Java Interview Questions
Nov 24, 2019 · Fundamentals

Introduction to the Singleton Design Pattern

The Singleton pattern ensures a class has only one instance, providing a global point of access, and is explained with its definition, implementation steps, advantages, disadvantages, thread‑safety concerns, usage guidelines, and typical real‑world scenarios such as configuration management, logging, and resource pooling.

Design PatternObject-Orientedjava
0 likes · 9 min read
Introduction to the Singleton Design Pattern
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.

Design PatternEnumLazy Initialization
0 likes · 10 min read
Java Singleton Pattern Implementations and Variants
Qunar Tech Salon
Qunar Tech Salon
Aug 8, 2019 · Frontend Development

Understanding Design Patterns in JavaScript

This article explains why and how to use various JavaScript design patterns—such as module, revealing module, ES6 modules, singleton, factory, and decorator—by describing their purpose, benefits, and providing clear code examples while warning against over‑use.

Design PatternsJavaScriptModule Pattern
0 likes · 14 min read
Understanding Design Patterns in JavaScript
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.

Design PatternEnumSerialization
0 likes · 12 min read
Is Your Java Singleton Really a Singleton? Thread, Reflection & Serialization Pitfalls
Java Captain
Java Captain
May 29, 2019 · Backend Development

Common Design Patterns Used in the Spring Framework

This article reviews the most frequently applied design patterns in Spring—including IoC/DI, Factory, Singleton, Proxy (AOP), Template Method, Observer, Adapter, and Decorator—explaining their purpose, how Spring implements them, and providing concise code examples for each.

AOPDesign PatternsIoC
0 likes · 17 min read
Common Design Patterns Used in the Spring Framework
Java Captain
Java Captain
Mar 9, 2019 · Fundamentals

Understanding Java Enums: Usage, Switch Cases, Singleton Implementation, and Database Integration

This article explores Java enums in depth, covering their basic definition, typical usage patterns such as iteration and switch statements, implementing singletons, integrating with databases via MyBatis type handlers, and addressing common misconceptions about memory consumption, illustrating each concept with clear code examples.

DatabaseEnumMyBatis
0 likes · 7 min read
Understanding Java Enums: Usage, Switch Cases, Singleton Implementation, and Database Integration
Java Captain
Java Captain
Feb 10, 2019 · Backend Development

Common Spring Design Patterns: Simple Factory, Factory Method, Singleton, Adapter, Decorator, Proxy, Observer, Strategy, and Template Method

This article explains how Spring implements nine classic design patterns—including Simple Factory, Factory Method, Singleton, Adapter, Decorator, Proxy, Observer, Strategy, and Template Method—through configuration examples and Java code, illustrating their roles in building flexible, maintainable backend applications.

Design PatternsFactory MethodSpring
0 likes · 9 min read
Common Spring Design Patterns: Simple Factory, Factory Method, Singleton, Adapter, Decorator, Proxy, Observer, Strategy, and Template Method
Senior Brother's Insights
Senior Brother's Insights
Jan 2, 2019 · Backend Development

9 Essential Spring Design Patterns Explained with Code Samples

This article walks through nine commonly used design patterns in Spring, such as Simple Factory, Factory Method, Singleton, Adapter, Wrapper, Proxy, Observer, Strategy, and Template Method, providing clear explanations, XML configurations, and Java code examples to illustrate each pattern in practice.

Design PatternsSpringadapter
0 likes · 9 min read
9 Essential Spring Design Patterns Explained with Code Samples
Java Captain
Java Captain
Oct 2, 2018 · Fundamentals

Understanding the Singleton Design Pattern in Java: Lazy, Eager, Double‑Check, Volatile, Static Inner Class and Enum Implementations

This article explains the Singleton design pattern in Java, covering its definition, the differences between lazy and eager implementations, thread‑safety issues, multiple code versions (simple, synchronized, double‑checked locking, volatile), and alternative approaches using static inner classes and enums, while discussing atomic operations and instruction reordering.

Design PatternEnumLazy Initialization
0 likes · 14 min read
Understanding the Singleton Design Pattern in Java: Lazy, Eager, Double‑Check, Volatile, Static Inner Class and Enum Implementations
Programmer DD
Programmer DD
Jun 6, 2018 · Fundamentals

Why Double‑Checked Locking Fails in Java and How to Fix It

This article explains why the classic Double‑Checked Locking implementation of a lazy singleton is unsafe in Java, analyzes the underlying object‑creation reordering problem, and presents two reliable solutions—using a volatile field or a static holder class—to achieve thread‑safe lazy initialization.

Volatileconcurrencydouble-checked locking
0 likes · 7 min read
Why Double‑Checked Locking Fails in Java and How to Fix It
Java Backend Technology
Java Backend Technology
Apr 17, 2018 · Backend Development

Mastering the Singleton Pattern in Java: Eager, Lazy, and Thread‑Safe Implementations

This article explains the concept of design patterns and dives deep into the Singleton pattern in Java, covering its purpose, eager and lazy implementations, thread‑safety challenges, double‑checked locking, volatile usage, static inner class, and enum approaches, while illustrating each with clear code examples and diagrams.

Design PatternDouble-Check LockingEnum
0 likes · 11 min read
Mastering the Singleton Pattern in Java: Eager, Lazy, and Thread‑Safe Implementations
Java Captain
Java Captain
Apr 14, 2018 · Fundamentals

Java Design Patterns: Singleton, Observer, Decorator, Adapter, Factory, Abstract Factory, and Proxy

This article introduces several core Java design patterns—including Singleton (lazy, eager, static inner class, enum, double‑checked locking), Observer, Decorator, Adapter, Factory, Abstract Factory, and Proxy—explaining their intent, providing concise code examples, and showing how they solve common software design problems.

Design Patternsdecoratorfactory
0 likes · 13 min read
Java Design Patterns: Singleton, Observer, Decorator, Adapter, Factory, Abstract Factory, and Proxy
Java Captain
Java Captain
Feb 6, 2018 · Backend Development

Will JVM Garbage Collector Reclaim Long-Unused Singleton Objects?

This article investigates whether the JVM garbage collector can reclaim singleton instances that remain unused for extended periods, presenting a test program, analyzing GC logs, and explaining the GC root mechanism that keeps static singleton references alive, concluding that HotSpot 1.6 does not collect such objects.

Garbage CollectionHotSpotJVM
0 likes · 6 min read
Will JVM Garbage Collector Reclaim Long-Unused Singleton Objects?
MaGe Linux Operations
MaGe Linux Operations
Jan 24, 2018 · Backend Development

Ace Alibaba Python Engineer Interview: Real Questions & Answers

This article shares Alibaba's Python engineer job requirements, detailed interview questions covering list operations, word frequency, GIL, multithreading, design patterns, and common Python concepts, along with concise answers to help candidates prepare effectively.

AlibabaCoding QuestionsGIL
0 likes · 10 min read
Ace Alibaba Python Engineer Interview: Real Questions & Answers
Java Captain
Java Captain
Jan 5, 2018 · Fundamentals

Overview of Design Patterns, SOLID Principles, and Java Implementations

This article introduces the three major categories of design patterns, explains the six SOLID principles, and provides detailed Java code examples for creational patterns such as Factory Method, Abstract Factory, Singleton, Builder, and Prototype, illustrating their structure and usage.

BuilderCreationalDesign Patterns
0 likes · 14 min read
Overview of Design Patterns, SOLID Principles, and Java Implementations
MaGe Linux Operations
MaGe Linux Operations
Dec 13, 2017 · Fundamentals

Unlock Python Metaprogramming: Master Metaclasses, Singletons, and Decorators

This article demystifies Python metaprogramming by exploring objects, classes, metaclasses, import‑time vs run‑time behavior, singleton implementations, decorators, and descriptors, showing how to harness these advanced features to write cleaner, more elegant code while explaining underlying concepts and practical examples.

MetaprogrammingPythondecorators
0 likes · 9 min read
Unlock Python Metaprogramming: Master Metaclasses, Singletons, and Decorators
Architecture Digest
Architecture Digest
Dec 13, 2017 · Mobile Development

Practical Code Refactoring Lessons from a Mobile Development Leader

The author, a mobile development team leader, shares a detailed account of a recent iOS codebase refactoring, describing the removal of unused libraries and code, architectural improvements, memory‑leak fixes, and best‑practice guidelines such as avoiding singletons, unnecessary layers, and over‑reliance on third‑party frameworks.

architecturecode cleanupiOS
0 likes · 11 min read
Practical Code Refactoring Lessons from a Mobile Development Leader
Programmer DD
Programmer DD
Dec 6, 2017 · Fundamentals

Mastering Java Singleton: From Lazy Initialization to Enum with Thread‑Safety

This article walks through multiple Java Singleton implementations—lazy initialization, double‑checked locking, volatile‑protected, static‑inner‑class, and enum—explaining their thread‑safety characteristics, the pitfalls of instruction reordering, and how reflection and serialization can break or preserve the pattern.

Design PatternEnumThread Safety
0 likes · 10 min read
Mastering Java Singleton: From Lazy Initialization to Enum with Thread‑Safety
Senior Brother's Insights
Senior Brother's Insights
Dec 4, 2017 · Fundamentals

Mastering Thread‑Safe Singleton in Java: Double‑Check, Static Holder, Enum & Reflection Hacks

Explore multiple Java singleton implementations—including a thread‑safe double‑checked locking version, a static inner‑class approach, an enum‑based solution, and a reflection‑based attack—while learning their key technical details, advantages, pitfalls, and how to protect against serialization and reflection vulnerabilities.

Design PatternEnumThread Safety
0 likes · 6 min read
Mastering Thread‑Safe Singleton in Java: Double‑Check, Static Holder, Enum & Reflection Hacks
Java Captain
Java Captain
Nov 13, 2017 · Fundamentals

Understanding the Singleton Design Pattern in Java: Implementations, Thread Safety, and Best Practices

This article explains the Singleton design pattern in Java, covering its definition, lazy and eager implementations, thread‑safety issues such as double‑checked locking and volatile, and alternative approaches like static inner classes and enums, providing code examples and practical insights.

Design PatternThread Safetydouble-checked locking
0 likes · 14 min read
Understanding the Singleton Design Pattern in Java: Implementations, Thread Safety, and Best Practices
Hujiang Technology
Hujiang Technology
Oct 26, 2017 · Frontend Development

Design Patterns in Front-End JavaScript Development

This article explains how to apply common design patterns such as Singleton and Observer in front‑end JavaScript, demonstrating practical extensions using Function.prototype, discussing the Open‑Closed Principle, and providing code examples for flexible, maintainable code without invasive modifications.

Design PatternsJavaScriptOpen-Closed Principle
0 likes · 10 min read
Design Patterns in Front-End JavaScript Development
Java Backend Technology
Java Backend Technology
Oct 24, 2017 · Fundamentals

ThreadLocal OOM? Exploring Singleton Pitfalls in Java Multithreading

This article examines common Java singleton implementations—including eager, thread‑safe lazy, double‑checked locking, and static inner‑class approaches—explaining their requirements, potential memory‑leak pitfalls such as ThreadLocal‑induced OOM, and how improper usage in multithreaded environments can lead to unexpected instance creation and performance issues.

Design PatternsOOMThreadLocal
0 likes · 6 min read
ThreadLocal OOM? Exploring Singleton Pitfalls in Java Multithreading
Hujiang Technology
Hujiang Technology
Jul 20, 2017 · Mobile Development

Kotlin Class Extensions, Companion Objects, Singleton Design, Dynamic Proxy, and Pseudo‑Multiple Inheritance

This article explains Kotlin's class extension functions, highlights pitfalls of static resolution, demonstrates smart casts, describes companion objects and singleton patterns, and shows how to implement dynamic proxies and pseudo‑multiple inheritance with practical code examples for Android development.

Class ExtensionsCompanion ObjectDynamic Proxy
0 likes · 11 min read
Kotlin Class Extensions, Companion Objects, Singleton Design, Dynamic Proxy, and Pseudo‑Multiple Inheritance
Tencent TDS Service
Tencent TDS Service
Mar 9, 2017 · Mobile Development

Mastering the Singleton Pattern in Android: Pitfalls, Best Practices, and Real‑World Implementations

This article explores the Singleton design pattern in depth, covering its definition, various Java implementations, thread‑safety concerns, serialization, reflection and cloning pitfalls, Android‑specific considerations, and practical recommendations for using singletons effectively in mobile projects.

Design PatternEnumThread Safety
0 likes · 38 min read
Mastering the Singleton Pattern in Android: Pitfalls, Best Practices, and Real‑World Implementations
Tencent Music Tech Team
Tencent Music Tech Team
Apr 27, 2016 · Mobile Development

Cross-Process Singleton Implementation in Android Using AIDL

The article explains how to turn a traditional Android singleton into a cross‑process object by having the singleton implement an AIDL interface, exposing it through a bound Service, and using Parcelable‑based Binder serialization so multiple processes share the same instance while handling IPC, threading, and data‑type constraints.

AIDLAndroidCross-Process
0 likes · 17 min read
Cross-Process Singleton Implementation in Android Using AIDL

Why the Singleton Pattern Matters: Lazy Loading, Thread Safety, and Real‑World Java Examples

This article explains the Singleton design pattern in Java, illustrates why a single instance is essential for configuration classes, compares eager and lazy initialization, shows thread‑safe implementations, and demonstrates extensions that limit the number of instances with practical code samples.

Design PatternThread Safetyjava
0 likes · 12 min read
Why the Singleton Pattern Matters: Lazy Loading, Thread Safety, and Real‑World Java Examples