Skip to main content
Guarded Suspension

Also known as

  • Conditional Block
  • Suspended Execution

Intent

The Guarded Suspension pattern manages operations that require both a lock and a condition to proceed, allowing a thread to wait for an appropriate condition while being efficient with resource use.


iluwatarAbout 2 minConcurrencyAsynchronousDecouplingResource managementSynchronizationThread management
Half-Sync/Half-Async

Also known as

  • Async-Sync Bridge
  • Half-Synchronous/Half-Asynchronous

Intent

The Half-Sync/Half-Async pattern aims to decouple asynchronous and synchronous processing in concurrent systems, allowing efficient interaction and data exchange between asynchronous and synchronous components.


iluwatarAbout 3 minConcurrencyAsynchronousDecouplingSynchronizationThread management
Leader/Followers

Intent

To manage a set of worker threads efficiently, where multiple threads take turns sharing a set of event sources in order to utilize fewer resources than one-thread-per-source.

Explanation

Real-world Example

Imagine managing a busy restaurant with multiple servers and a single host. The host acts as the "leader" and is responsible for greeting guests, managing the waitlist, and seating guests. Once the guests are seated, the host returns to the entrance to manage new arrivals. The servers, or "followers," wait for the host to assign them tables. This assignment is done on a rotational basis where the next available server takes the next group of guests. This system ensures that the host efficiently handles the incoming flow of guests while servers focus on providing service, similar to how the Leader and Followers pattern manages threads and tasks in a software system. This approach optimizes resource utilization (in this case, staff) and ensures smooth operations during peak times, much like it optimizes thread usage in computing environments.


iluwatarAbout 3 minConcurrencyDecouplingPerformanceSynchronizationThread management
Lockable Object

Also known as

  • Resource Lock
  • Mutual Exclusion Object

Intent

The Lockable Object pattern aims to control access to a shared resource in a multithreaded environment by providing a mechanism for resource locking, ensuring that only one thread can access the resource at a time.


iluwatarAbout 3 minConcurrencyDecouplingEncapsulationSecuritySynchronizationThread management