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

Implement Thread-Pool Executor pattern #3226

Open
6 tasks
iluwatar opened this issue Mar 30, 2025 · 0 comments
Open
6 tasks

Implement Thread-Pool Executor pattern #3226

iluwatar opened this issue Mar 30, 2025 · 0 comments

Comments

@iluwatar
Copy link
Owner

Description

The Thread-Pool Executor is a concurrency design pattern that maintains a pool of worker threads to process tasks. Rather than creating a new thread each time a task is submitted, the pattern reuses existing threads in the pool. This leads to more efficient CPU usage, less overhead from thread creation/destruction, and improved overall application performance.

Key Elements

  • Thread Pool: A fixed or dynamically sized set of threads that carry out tasks.
  • Task Submission: Tasks (e.g., Runnable or Callable) are placed in a queue for execution.
  • Executor / ExecutorService: Provides an interface for submitting tasks (execute, submit) and managing the pool (shutdown, etc.).
  • Resource Management: Reusing threads reduces overhead and improves response time in high-load scenarios.

References

  1. Java Documentation for ThreadPoolExecutor
  2. Java Concurrency in Practice (Brian Goetz)
  3. Java Design Patterns - Contribution Guidelines

Acceptance Criteria

  • Create a new module or package named thread-pool-executor (or similar).
  • Demonstrate how tasks can be submitted to an executor service and processed by a pool of threads.
  • Provide a README (or .md file) explaining the pattern, including code examples, diagrams, or both.
  • Ensure all code follows the repository’s style, naming conventions, and best practices.
  • Include unit tests that confirm correct behavior under load (multiple tasks) and confirm proper shutdown.
  • Pass all continuous integration checks and meet the project’s contribution guidelines.
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

1 participant