Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coarse-Grained Lock pattern #1289

Open
iluwatar opened this issue Jul 7, 2020 · 2 comments
Open

Coarse-Grained Lock pattern #1289

iluwatar opened this issue Jul 7, 2020 · 2 comments

Comments

@iluwatar
Copy link
Owner

iluwatar commented Jul 7, 2020

Description

The Coarse-Grained Lock design pattern is a concurrency control strategy where a single lock is used to protect a large portion of code or multiple related resources. This approach simplifies lock management by reducing the number of locks needed and minimizing the potential for deadlocks. However, it can reduce concurrency as the coarse-grained lock may force threads to wait even when they could safely proceed.

Main Elements of the Pattern:

  • Single Lock Mechanism: One lock protects a large code segment or multiple resources.
  • Simplicity: Easier to implement and manage compared to fine-grained locks.
  • Reduced Concurrency: May lead to lower parallelism as threads may be unnecessarily blocked.

Implementation Steps:

  1. Identify the critical section or related resources that require protection.
  2. Implement a single lock to guard the entire critical section or group of resources.
  3. Ensure that the lock is acquired at the beginning and released at the end of the critical section.

References

Acceptance Criteria

  1. Implement a Coarse-Grained Lock in a chosen example within the project.
  2. Ensure the implementation follows the contribution guidelines provided in the project repository.
  3. Include comprehensive unit tests demonstrating the effectiveness and correctness of the Coarse-Grained Lock implementation.
@SpaceIshtar
Copy link

Hi, I would like to have a try. Can you assign it to me?

@iluwatar
Copy link
Owner Author

Yes, go ahead @SpaceIshtar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

No branches or pull requests

2 participants