- 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.
推薦閱讀
- Mastering OpenLayers 3
- Implementing Modern DevOps
- 算法零基礎一本通(Python版)
- JavaScript 網頁編程從入門到精通 (清華社"視頻大講堂"大系·網絡開發視頻大講堂)
- 精通軟件性能測試與LoadRunner實戰(第2版)
- 網店設計看這本就夠了
- Rust Essentials(Second Edition)
- Jupyter數據科學實戰
- Java Fundamentals
- Learning Material Design
- PostgreSQL Developer's Guide
- SAP Web Dynpro for ABAP開發技術詳解:基礎應用
- HTML5+CSS3+jQuery Mobile+Bootstrap開發APP從入門到精通(視頻教學版)
- Zend Framework 2 Cookbook
- Swift Essentials(Second Edition)