From 79fc4f2c0dfd974211b0974aec1d7d5bfdf598d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ilkka=20Sepp=C3=A4l=C3=A4?= Date: Sun, 26 May 2024 13:53:27 +0300 Subject: [PATCH] docs: update leader/followers and lockable object --- leader-followers/README.md | 2 +- lockable-object/README.md | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/leader-followers/README.md b/leader-followers/README.md index f593c9e80..ce627345f 100644 --- a/leader-followers/README.md +++ b/leader-followers/README.md @@ -169,5 +169,5 @@ Trade-offs: ## Credits -* [Pattern-Oriented Software Architecture Volume 2: Patterns for Concurrent and Networked Objects](https://amzn.to/3UgC24V) * [Java Concurrency in Practice](https://amzn.to/4aRMruW) +* [Pattern-Oriented Software Architecture Volume 2: Patterns for Concurrent and Networked Objects](https://amzn.to/3UgC24V) diff --git a/lockable-object/README.md b/lockable-object/README.md index c4bfef6a8..09ac9e857 100644 --- a/lockable-object/README.md +++ b/lockable-object/README.md @@ -21,7 +21,7 @@ The Lockable Object pattern aims to control access to a shared resource in a mul ## Explanation -Real world example +Real-world example > Imagine a shared printer in a busy office as an analogous real-world example of the Lockable Object design pattern. Multiple employees need to print documents throughout the day, but the printer can only handle one print job at a time. To manage this, there's a locking system in place—much like a lockable object in programming—that ensures when one person is printing, others must wait their turn. This prevents print jobs from overlapping or interfering with each other, ensuring that each document is printed correctly and in the order it was sent, mirroring the concept of thread synchronization and resource locking in software development. @@ -39,8 +39,6 @@ The Lockable Object pattern is a concurrency pattern that allows only one thread In this example, we have a `SwordOfAragorn` object that implements the `Lockable` interface. Multiple `Creature` objects, represented by `Elf`, `Orc`, and `Human` classes, are trying to acquire the sword. Each `Creature` is wrapped in a `Feind` object that implements `Runnable`, allowing each creature to attempt to acquire the sword in a separate thread. -## Code Snippets - Here's the `Lockable` interface: ```java @@ -154,8 +152,8 @@ Trade-offs: ## Related Patterns -[Monitor Object](https://java-design-patterns.com/patterns/monitor/): Both patterns manage access to shared resources; Monitor Object combines synchronization and encapsulation of the condition variable. -[Read/Write Lock](https://java-design-patterns.com/patterns/reader-writer-lock/): Specialization of Lockable Object for scenarios where read operations outnumber write operations. +* [Monitor Object](https://java-design-patterns.com/patterns/monitor/): Both patterns manage access to shared resources; Monitor Object combines synchronization and encapsulation of the condition variable. +* [Read/Write Lock](https://java-design-patterns.com/patterns/reader-writer-lock/): Specialization of Lockable Object for scenarios where read operations outnumber write operations. ## Credits