Origin: | Gof 95 | |||
Reason: | Ensure that at most one instance of a certain class is created. | |||
Synopsis: | Define a class with a private constructor and a public static getInstance method that always return the same instance. | |||
Example: | An applet class that ensures that no more than one audioclip is played at a time. | |||
Solution: |
|
|||
See also: |
Immutable |
|||
Note: | Java serialization, concurrency, and garbage collection make this a "weak" pattern. |