Singleton analysis application in the source JDK || Note Singleton and detail description

Singleton in JDK analysis application's source code

Singleton analysis application in the source JDK
1) We JDK in, java.lang.Runtime is a classic example of the single-mode ( starving style )
2) code analysis + the Debug source + Code Description
 
 


Singleton notes and detailed instructions

1) Singleton pattern to ensure that the memory system there is only one object class , saving system resources, to create some objects that require frequent destruction, single-use-case model can improve system performance

2) When a single embodiment want to instantiate class, you must remember to use the corresponding method for acquiring an object , instead of using the new

3) Scene Singleton used : require frequent creation and destruction of objects , consuming too much or consume too many resources (that is, when you create an object: heavyweight objects), but frequently used objects , tools Objects , frequent access to the database files or objects (such as the data source, session factories, etc.)

 
Published 434 original articles · won praise 105 · views 70000 +

Guess you like

Origin blog.csdn.net/qq_39368007/article/details/104934716
Recommended