🏠 Home
Benchmark
📊 Tutti i benchmark 🦖 Dinosauro v1 🦖 Dinosauro v2 ✅ App To-Do List 🎨 Pagine libere creative 🎯 FSACB - Ultimate Showcase 🌍 Benchmark traduzione
Modelli
🏆 Top 10 modelli 🆓 Modelli gratuiti 📋 Tutti i modelli ⚙️ Kilo Code
Risorse
💬 Libreria di prompt 📖 Glossario IA 🔗 Link utili
Advanced

Thread-Safe Singleton Factory Refactoring

#refactoring #design-patterns #concurrency #java

Refactor a legacy class into a thread-safe Singleton using the Double-Checked Locking pattern.

Analyze the provided legacy Java class which manages database connections. Identify thread-safety issues and violations of the Single Responsibility Principle. Refactor the class to implement the Singleton design pattern using the Double-Checked Locking mechanism to ensure high performance in a multi-threaded environment. Additionally, extract the connection creation logic into a Factory pattern. Provide the refactored code with detailed comments explaining the memory visibility implications of the 'volatile' keyword used in the context.