23 design modes - single case mode
Singleton mode
Reference documents
Singleton Pattern is one of the simplest design patterns in Java. This type of design pattern is a creation pattern, which provides the best way to create objects. This pattern involves a single class that is responsible for creating its own objects while ensuring that only a single object is created. Thi ...
Posted by Sonu Kapoor on Mon, 31 Jan 2022 01:44:59 +0100
C + + multi thread online learning (13-07)
1. Overview of design mode
[concept] some writing methods of code: flexible program and convenient maintenance; But the code is obscure and not easy for others to take over.
2. Single case design mode
[concept]: there is one or some special class in the whole project. Only one object belonging to this class can be created.
3. Shared dat ...
Posted by zamzon on Sat, 29 Jan 2022 21:07:04 +0100
101 singleton mode (creation type)
1. Single case introduction
Definition: Ensure a class has only one instance, and provide a global point of access to it
(ensure that a class has only one instance, and instantiate it by itself and provide this instance to the whole system.)
Concept: an object can only create one instance
Follow the rule: privatize the constructor and obtai ...
Posted by smartknightinc on Sat, 29 Jan 2022 00:59:42 +0100
LeakCanary source code analysis
Memory leak
Memory leak caused by single case
public class SingletonActivityContext {
private static SingletonActivityContext instance;
private Context context;
private SingletonActivityContext(Context context) {
this.context = context;
}
public static SingletonActivityContext getInstance(Context context) {
...
Posted by spiceydog on Thu, 27 Jan 2022 07:47:13 +0100
03_ Single case design mode
1 Introduction to single example design mode
Class singleton design pattern is to take certain methods to ensure that there can only be one object instance for a class in the whole software system, and the class only provides a method to obtain the object instance (static method).
2. There are eight ways of single case design mode
2.1 hungry ...
Posted by pod2oo5 on Tue, 25 Jan 2022 10:31:09 +0100
Implementation of snowflake algorithm in singleton mode
Snowflake algorithm
The snowflake algorithm is suitable for generating globally unique numbers, such as database primary key id, order number, etc
As for why it is called snowflake algorithm, it is because scientists believe that there are no two identical snowflakes in nature through research. Therefore, this algorithm is named ...
Posted by Popgun on Sun, 23 Jan 2022 14:02:09 +0100
Singleton pattern
1, Brief description
The singleton pattern is the simplest in Java Design pattern one of. This type of design pattern is a creation pattern, which provides the best way to create objects. This pattern involves a single class that is responsible for creating its own objects while ensuring that only a single object is created. This class provide ...
Posted by ywickham on Fri, 21 Jan 2022 18:34:33 +0100
[self research framework I] self research framework IoC container and single instance mode
Use of self-developed frame IoC container
The most basic functions of the framework
◆ resolution configuration ◆ locate and register the object, which is a mark (annotation). After locating the object, you need to register the object in the container ◆ inject the object and return the object to the user accurately when the user needs it
◆ ...
Posted by firedrop on Tue, 18 Jan 2022 13:54:52 +0100
Mode 23: (single row mode)
catalogue
Singleton design pattern
Introduction to single example design mode
Eight ways of single case design mode
Hungry Han formula (static constant)
Hungry Chinese (static code block)
Lazy (thread unsafe)
Lazy (thread safety, synchronization method)
Lazy (thread safe, synchronous code block)
Static inner class
enumeration
Source ...
Posted by mellowman on Tue, 18 Jan 2022 01:54:51 +0100
Summary and extension of thread synchronization
Thread synchronization mechanism
Thread synchronization refers to multiple threads operating on the same resource
Concurrency means that the same object is operated by multiple threads at the same time
in real life
,
We'll meet“
Same resource
,
Many people want to use it
"
Question of
,
such as
,
In the canteen,
Everyone ...
Posted by ferozsho on Sat, 15 Jan 2022 21:14:11 +0100