mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-10-12 02:14:07 +00:00
docs: improve lockable object
This commit is contained in:
1 parent
30cb9af12b
commit
92ae818fe2
10 files changed
+116
-241
No files matched your search
@@ -42,8 +42,8 @@ import lombok.extern.slf4j.Slf4j;
|
||||
* the request.
|
||||
*
|
||||
* <p>In this example, we create a new Lockable object with the SwordOfAragorn implementation of it.
|
||||
* Afterwards we create 6 Creatures with the Elf, Orc and Human implementations and assign them each
|
||||
* to a Fiend object and the Sword is the target object. Because there is only one Sword and it uses
|
||||
* Afterward we create 6 Creatures with the Elf, Orc and Human implementations and assign them each
|
||||
* to a Fiend object and the Sword is the target object. Because there is only one Sword, and it uses
|
||||
* the Lockable Object pattern, only one creature can hold the sword at a given time. When the sword
|
||||
* is locked, any other alive Fiends will try to lock, which will result in a race to lock the
|
||||
* sword.
|
||||
|
||||
Reference in new issue
Block a user