- Spring 5 Design Patterns
- Dinesh Rajput
- 127字
- 2021-07-08 09:59:32
Common problems where you should apply Singleton pattern
The Singleton pattern solves only one problem--if you have a resource that can only have a single instance, and you need to manage that single instance, then you need a singleton. Normally, if you want to create a database connection with the given configuration in the distributed and multithread environment, it might be the case that every thread can create a new database connection with a different configuration object, if you don't follow the singleton design. With the Singleton pattern, each thread gets the same database connection object with the same configuration object across the system. It is mostly used in multithreaded and database applications. It is used in logging, caching, thread pools, configuration settings, and so on.
推薦閱讀
- 在最好的年紀學Python:小學生趣味編程
- Java應用與實戰(zhàn)
- SQL學習指南(第3版)
- PyTorch自然語言處理入門與實戰(zhàn)
- Raspberry Pi for Secret Agents(Third Edition)
- UI智能化與前端智能化:工程技術、實現方法與編程思想
- VMware虛擬化技術
- 全棧自動化測試實戰(zhàn):基于TestNG、HttpClient、Selenium和Appium
- WordPress 4.0 Site Blueprints(Second Edition)
- NetBeans IDE 8 Cookbook
- Beginning C++ Game Programming
- Advanced Python Programming
- Android Studio開發(fā)實戰(zhàn):從零基礎到App上線 (移動開發(fā)叢書)
- 讀故事學編程:Python王國歷險記
- Mastering Magento Theme Design