mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-08-20 08:23:52 +00:00
docs: add diagrams for decorator, delegation, dependency injection, dirty flag, domain model, double buffer, double-checked locking, double dispatch, and dynamic proxy
This commit is contained in:
@@ -29,6 +29,10 @@ Wikipedia says
|
||||
|
||||
> In software engineering, double-checked locking (also known as "double-checked locking optimization") is a software design pattern used to reduce the overhead of acquiring a lock by testing the locking criterion (the "lock hint") before acquiring the lock. Locking occurs only if the locking criterion check indicates that locking is required.
|
||||
|
||||
Flowchart
|
||||
|
||||

|
||||
|
||||
## Programmatic Example of Double-Checked Locking Pattern in Java
|
||||
|
||||
The Double-Checked Locking pattern is used in the `HolderThreadSafe` class to ensure that the `Heavy` object is only created once, even when accessed from multiple threads. Here's how it works:
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 67 KiB |
Reference in New Issue
Block a user