mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-14 10:58:42 +00:00
docs: Content SEO updates (#2990)
* update yaml frontmatter format * update abstract document * update abstract factory * use the new pattern template * acyclic visitor seo * adapter seo * ambassador seo * acl seo * aaa seo * async method invocation seo * balking seo * bridge seo * builder seo * business delegate and bytecode seo * caching seo * callback seo * chain seo * update headings * circuit breaker seo * client session + collecting parameter seo * collection pipeline seo * combinator SEO * command seo * cqrs seo * commander seo * component seo * composite seo * composite entity seo * composite view seo * context object seo * converter seo * crtp seo * currying seo * dao seo * data bus seo * data locality seo * data mapper seo * dto seo * decorator seo * delegation seo * di seo * dirty flag seo * domain model seo * double buffer seo * double checked locking seo * double dispatch seo * dynamic proxy seo * event aggregator seo * event-based asynchronous seo * eda seo * event queue seo * event sourcing seo * execute around seo * extension objects seo * facade seo * factory seo * factory kit seo * factory method seo * fanout/fanin seo * feature toggle seo * filterer seo * fluent interface seo * flux seo * flyweight seo * front controller seo * function composition seo * game loop seo * gateway seo * guarded suspension seo * half-sync/half-async seo * health check seo * hexagonal seo * identity map seo * intercepting filter seo * interpreter seo * iterator seo * layers seo * lazy loading seo * leader election seo * leader/followers seo * lockable object seo * rename and add seo for marker interface * master-worker seo * mediator seo * memento seo * metadata mapping seo * microservice aggregator seo * api gw seo * microservices log aggregration seo * mvc seo * mvi seo * mvp seo * mvvm seo * monad seo * monitor seo * monostate seo * multiton seo * mute idiom seo * naked objects & notification seo * null object seo * object mother seo * object pool seo * observer seo * optimistic locking seo * page controller seo * page object seo * parameter object seo * partial response seo * pipeline seo * poison pill seo * presentation model seo * private class data seo * producer-consumer seo * promise seo * property seo * prototype seo * proxy seo * queue-based load leveling seo * reactor seo * registry seo * repository seo * RAII seo * retry seo * role object seo * saga seo * separated interface seo * serialized entity seo * serialized lob seo * servant seo * server session seo * service layer seo * service locator seo * service to worker seo * sharding seo * single table inheritance seo * singleton seo * spatial partition seo * special case seo * specification seo * state seo * step builder seo * strangler seo * strategy seo * subclass sandbox seo * table module seo * template method seo * throttling seo * tolerant reader seo * trampoline seo * transaction script seo * twin seo * type object seo * unit of work seo * update method seo * value object seo * version number seo * virtual proxy seo * visitor seo * seo enhancements * seo improvements * SEO enhancements * SEO improvements * SEO additions * SEO improvements * more SEO improvements * rename hexagonal + SEO improvements * SEO improvements * more SEO stuff * SEO improvements * SEO optimizations * SEO enhancements * enchance SEO * improve SEO * SEO improvements * update headers
This commit is contained in:
@@ -1,26 +1,28 @@
|
||||
---
|
||||
title: Event-Based Asynchronous
|
||||
title: "Event-Based Asynchronous Pattern in Java: Mastering Non-Blocking System Design"
|
||||
shortTitle: Event-Based Asynchronous
|
||||
description: "Explore the best practices and implementations of event-based asynchronous patterns in Java. Enhance your programming skills with our comprehensive guide and real-world examples."
|
||||
category: Concurrency
|
||||
language: en
|
||||
tag:
|
||||
- Asynchronous
|
||||
- Decoupling
|
||||
- Event-driven
|
||||
- Fault tolerance
|
||||
- Messaging
|
||||
- Reactive
|
||||
- Scalability
|
||||
- Asynchronous
|
||||
- Decoupling
|
||||
- Event-driven
|
||||
- Fault tolerance
|
||||
- Messaging
|
||||
- Reactive
|
||||
- Scalability
|
||||
---
|
||||
|
||||
## Also known as
|
||||
|
||||
* Asynchronous Event Handling
|
||||
|
||||
## Intent
|
||||
## Intent of Event-Based Asynchronous Design Pattern
|
||||
|
||||
The Event-Based Asynchronous pattern allows a system to handle tasks that might take some time to complete without blocking the execution of the program. It enables better resource utilization by freeing up a thread that would otherwise be blocked waiting for the task to complete.
|
||||
|
||||
## Explanation
|
||||
## Detailed Explanation of Event-Based Asynchronous Pattern with Real-World Examples
|
||||
|
||||
Real-world example
|
||||
|
||||
@@ -30,9 +32,9 @@ In Plain Words
|
||||
|
||||
> The Event-Based Asynchronous design pattern allows tasks to be executed in the background, notifying the main program via events when completed, thereby enhancing system efficiency and responsiveness without blocking ongoing operations.
|
||||
|
||||
**Programmatic Example**
|
||||
## Programmatic Example of Event-Based Asynchronous Pattern in Java
|
||||
|
||||
The Event-Based Asynchronous design pattern allows tasks to be executed in the background, notifying the main program via events when completed. This enhances system efficiency and responsiveness without blocking ongoing operations.
|
||||
Event-Based Asynchronous design pattern allows tasks to be executed in the background, notifying the main program via events when completed, thereby enhancing system efficiency and responsiveness without blocking ongoing operations.
|
||||
|
||||
In the provided code, we have several key classes implementing this pattern:
|
||||
|
||||
@@ -141,20 +143,20 @@ In this snippet, when a `SyncEvent` is started, it runs on the main thread, bloc
|
||||
|
||||
These are the key parts of the Event-Based Asynchronous design pattern as implemented in this code. The pattern allows tasks to be executed in the background, notifying the main program via events when completed, thereby enhancing system efficiency and responsiveness without blocking ongoing operations.
|
||||
|
||||
## Applicability
|
||||
## When to Use the Event-Based Asynchronous Pattern in Java
|
||||
|
||||
* When multiple tasks can be processed in parallel and independently.
|
||||
* Systems that require responsiveness and cannot afford to have threads blocked waiting for an operation to complete.
|
||||
* In GUI applications where user interface responsiveness is critical.
|
||||
* Distributed systems where long network operations are involved.
|
||||
|
||||
## Known Uses
|
||||
## Real-World Applications of Event-Based Asynchronous Pattern in Java
|
||||
|
||||
* GUI libraries in Java (e.g., JavaFX, Swing with SwingWorker).
|
||||
* Java Message Service (JMS) for handling asynchronous messaging.
|
||||
* Java’s CompletableFuture and various Event-Driven Frameworks.
|
||||
|
||||
## Consequences
|
||||
## Benefits and Trade-offs of Event-Based Asynchronous Pattern
|
||||
|
||||
Benefits:
|
||||
|
||||
@@ -167,13 +169,13 @@ Trade-offs:
|
||||
* Increases complexity of error handling as errors may occur in different threads or at different times.
|
||||
* Can lead to harder-to-follow code and debugging challenges due to the non-linear nature of asynchronous code execution.
|
||||
|
||||
Related Patterns
|
||||
## Related Java Design Patterns
|
||||
|
||||
* [Observer](https://java-design-patterns.com/patterns/observer/): Often used in conjunction where the observer reacts to events as they occur.
|
||||
* Publish/Subscribe: Related in terms of event handling mechanisms, particularly for messaging and event distribution across components.
|
||||
* [Command](https://java-design-patterns.com/patterns/command/): Useful for encapsulating all information needed to perform an action or trigger an event.
|
||||
|
||||
## Credits
|
||||
## References and Credits
|
||||
|
||||
* [Java Concurrency in Practice](https://amzn.to/4cYY4kU)
|
||||
* [Patterns of Enterprise Application Architecture](https://amzn.to/3Uh7rW1)
|
||||
|
||||
Reference in New Issue
Block a user