Skip to content

Conversation

@yybmion
Copy link
Contributor

@yybmion yybmion commented Apr 29, 2025

Pull Request Template

What does this PR do?

This PR implements the Thread-Pool Executor pattern, which demonstrates how a pool of worker threads can be used to execute tasks concurrently. It includes a complete implementation with a hotel front desk example, comprehensive tests, and detailed documentation.

Key Features

  • Adds FrontDeskService class that manages a thread pool for hotel employees
  • Implements GuestCheckInTask (Runnable) for regular guest check-ins
  • Implements VipGuestCheckInTask (Callable) for VIP guest check-ins with results
  • Includes comprehensive tests verifying correct behavior under load and proper shutdown
  • Provides detailed README with pattern explanation, class diagrams, and examples

Related Issue

Closes #3226

@github-actions
Copy link

github-actions bot commented Apr 29, 2025

PR Summary

This PR implements the Thread-Pool Executor pattern using a hotel front desk example. It includes a FrontDeskService class managing a thread pool, GuestCheckInTask for regular guests, and VipGuestCheckInTask for VIP guests. Comprehensive tests and a detailed README with diagrams are also provided.

Changes

File Summary
pom.xml The thread-pool-executor module was added to the project.
thread-pool-executor/README.md A comprehensive README was added, explaining the Thread-Pool Executor pattern, including real-world examples, class diagrams, and a Java code example using a hotel front desk scenario.
thread-pool-executor/etc/thread-pool-executor.urm.png New file.
thread-pool-executor/etc/thread-pool-executor.urm.puml PlantUML class diagram for the Thread-Pool Executor pattern was added.
thread-pool-executor/pom.xml The pom.xml file for the thread-pool-executor module was added, defining dependencies and build configurations.
thread-pool-executor/src/main/java/com/iluwatar/threadpoolexecutor/App.java This class demonstrates the Thread-Pool Executor pattern by simulating a hotel front desk managing guest check-ins using ExecutorService.
thread-pool-executor/src/main/java/com/iluwatar/threadpoolexecutor/FrontDeskService.java This class manages a thread pool of employees to handle guest check-ins, using ExecutorService for task submission and management.
thread-pool-executor/src/main/java/com/iluwatar/threadpoolexecutor/GuestCheckInTask.java This class represents a regular guest check-in task, implementing Runnable to perform the check-in process.
thread-pool-executor/src/main/java/com/iluwatar/threadpoolexecutor/VipGuestCheckInTask.java This class represents a VIP guest check-in task, implementing Callable to perform the check-in and return a result.
thread-pool-executor/src/test/java/com/iluwatar/threadpoolexecutor/AppTest.java This test class verifies that the main application class starts without throwing any exceptions.
thread-pool-executor/src/test/java/com/iluwatar/threadpoolexecutor/FrontDeskServiceTest.java This test class contains multiple tests for the FrontDeskService, covering various scenarios like task submission, shutdown, and concurrent task execution.
thread-pool-executor/src/test/java/com/iluwatar/threadpoolexecutor/GuestCheckInTaskTest.java This test class verifies that the GuestCheckInTask executes correctly and captures the current thread name.
thread-pool-executor/src/test/java/com/iluwatar/threadpoolexecutor/VipGuestCheckInTaskTest.java This test class verifies that the VipGuestCheckInTask returns the expected result string after execution.

autogenerated by presubmit.ai

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Review Summary

Commits Considered (1)
  • b83a609: feat: Implement Thread-Pool Executor pattern

  • Add implementation of Thread-Pool Executor pattern using hotel front desk example

  • Include unit tests

  • Create detailed README with pattern explanation and examples

  • Add Java source code with appropriate Javadoc comments

Closes #3226

Files Processed (13)
  • pom.xml (1 hunk)
  • thread-pool-executor/README.md (1 hunk)
  • thread-pool-executor/etc/thread-pool-executor.urm.png (0 hunks)
  • thread-pool-executor/etc/thread-pool-executor.urm.puml (1 hunk)
  • thread-pool-executor/pom.xml (1 hunk)
  • thread-pool-executor/src/main/java/com/iluwatar/threadpoolexecutor/App.java (1 hunk)
  • thread-pool-executor/src/main/java/com/iluwatar/threadpoolexecutor/FrontDeskService.java (1 hunk)
  • thread-pool-executor/src/main/java/com/iluwatar/threadpoolexecutor/GuestCheckInTask.java (1 hunk)
  • thread-pool-executor/src/main/java/com/iluwatar/threadpoolexecutor/VipGuestCheckInTask.java (1 hunk)
  • thread-pool-executor/src/test/java/com/iluwatar/threadpoolexecutor/AppTest.java (1 hunk)
  • thread-pool-executor/src/test/java/com/iluwatar/threadpoolexecutor/FrontDeskServiceTest.java (1 hunk)
  • thread-pool-executor/src/test/java/com/iluwatar/threadpoolexecutor/GuestCheckInTaskTest.java (1 hunk)
  • thread-pool-executor/src/test/java/com/iluwatar/threadpoolexecutor/VipGuestCheckInTaskTest.java (1 hunk)
Actionable Comments (0)
Skipped Comments (0)
@yybmion yybmion force-pushed the thread-pool-executor branch from b83a609 to 7f2f1fd Compare April 29, 2025 21:07
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Review Summary

Commits Considered (1)
  • 7f2f1fd: feat: Implement Thread-Pool Executor pattern

  • Add implementation of Thread-Pool Executor pattern using hotel front desk example

  • Include unit tests

  • Create detailed README with pattern explanation and examples

  • Add Java source code with appropriate Javadoc comments

Closes #3226

Files Processed (13)
  • pom.xml (1 hunk)
  • thread-pool-executor/README.md (1 hunk)
  • thread-pool-executor/etc/thread-pool-executor.urm.png (0 hunks)
  • thread-pool-executor/etc/thread-pool-executor.urm.puml (1 hunk)
  • thread-pool-executor/pom.xml (1 hunk)
  • thread-pool-executor/src/main/java/com/iluwatar/threadpoolexecutor/App.java (1 hunk)
  • thread-pool-executor/src/main/java/com/iluwatar/threadpoolexecutor/FrontDeskService.java (1 hunk)
  • thread-pool-executor/src/main/java/com/iluwatar/threadpoolexecutor/GuestCheckInTask.java (1 hunk)
  • thread-pool-executor/src/main/java/com/iluwatar/threadpoolexecutor/VipGuestCheckInTask.java (1 hunk)
  • thread-pool-executor/src/test/java/com/iluwatar/threadpoolexecutor/AppTest.java (1 hunk)
  • thread-pool-executor/src/test/java/com/iluwatar/threadpoolexecutor/FrontDeskServiceTest.java (1 hunk)
  • thread-pool-executor/src/test/java/com/iluwatar/threadpoolexecutor/GuestCheckInTaskTest.java (1 hunk)
  • thread-pool-executor/src/test/java/com/iluwatar/threadpoolexecutor/VipGuestCheckInTaskTest.java (1 hunk)
Actionable Comments (0)
Skipped Comments (0)
@yybmion yybmion force-pushed the thread-pool-executor branch from 7f2f1fd to 3d8fa01 Compare April 29, 2025 21:32
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Review Summary

Commits Considered (1)
  • 3d8fa01: feat: Implement Thread-Pool Executor pattern

  • Add implementation of Thread-Pool Executor pattern using hotel front desk example

  • Include unit tests

  • Create detailed README with pattern explanation and examples

  • Add Java source code with appropriate Javadoc comments

Closes #3226

Files Processed (13)
  • pom.xml (1 hunk)
  • thread-pool-executor/README.md (1 hunk)
  • thread-pool-executor/etc/thread-pool-executor.urm.png (0 hunks)
  • thread-pool-executor/etc/thread-pool-executor.urm.puml (1 hunk)
  • thread-pool-executor/pom.xml (1 hunk)
  • thread-pool-executor/src/main/java/com/iluwatar/threadpoolexecutor/App.java (1 hunk)
  • thread-pool-executor/src/main/java/com/iluwatar/threadpoolexecutor/FrontDeskService.java (1 hunk)
  • thread-pool-executor/src/main/java/com/iluwatar/threadpoolexecutor/GuestCheckInTask.java (1 hunk)
  • thread-pool-executor/src/main/java/com/iluwatar/threadpoolexecutor/VipGuestCheckInTask.java (1 hunk)
  • thread-pool-executor/src/test/java/com/iluwatar/threadpoolexecutor/AppTest.java (1 hunk)
  • thread-pool-executor/src/test/java/com/iluwatar/threadpoolexecutor/FrontDeskServiceTest.java (1 hunk)
  • thread-pool-executor/src/test/java/com/iluwatar/threadpoolexecutor/GuestCheckInTaskTest.java (1 hunk)
  • thread-pool-executor/src/test/java/com/iluwatar/threadpoolexecutor/VipGuestCheckInTaskTest.java (1 hunk)
Actionable Comments (0)
Skipped Comments (0)
- Add implementation of Thread-Pool Executor pattern using hotel front desk example - Include unit tests - Create detailed README with pattern explanation and examples - Add Java source code with appropriate Javadoc comments Closes iluwatar#3226
@yybmion yybmion force-pushed the thread-pool-executor branch from 3d8fa01 to 3ac5ce7 Compare April 29, 2025 22:27
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Review Summary

Commits Considered (1)
  • 3ac5ce7: feat: Implement Thread-Pool Executor pattern

  • Add implementation of Thread-Pool Executor pattern using hotel front desk example

  • Include unit tests

  • Create detailed README with pattern explanation and examples

  • Add Java source code with appropriate Javadoc comments

Closes #3226

Files Processed (13)
  • pom.xml (1 hunk)
  • thread-pool-executor/README.md (1 hunk)
  • thread-pool-executor/etc/thread-pool-executor.urm.png (0 hunks)
  • thread-pool-executor/etc/thread-pool-executor.urm.puml (1 hunk)
  • thread-pool-executor/pom.xml (1 hunk)
  • thread-pool-executor/src/main/java/com/iluwatar/threadpoolexecutor/App.java (1 hunk)
  • thread-pool-executor/src/main/java/com/iluwatar/threadpoolexecutor/FrontDeskService.java (1 hunk)
  • thread-pool-executor/src/main/java/com/iluwatar/threadpoolexecutor/GuestCheckInTask.java (1 hunk)
  • thread-pool-executor/src/main/java/com/iluwatar/threadpoolexecutor/VipGuestCheckInTask.java (1 hunk)
  • thread-pool-executor/src/test/java/com/iluwatar/threadpoolexecutor/AppTest.java (1 hunk)
  • thread-pool-executor/src/test/java/com/iluwatar/threadpoolexecutor/FrontDeskServiceTest.java (1 hunk)
  • thread-pool-executor/src/test/java/com/iluwatar/threadpoolexecutor/GuestCheckInTaskTest.java (1 hunk)
  • thread-pool-executor/src/test/java/com/iluwatar/threadpoolexecutor/VipGuestCheckInTaskTest.java (1 hunk)
Actionable Comments (0)
Skipped Comments (0)
@iluwatar iluwatar merged commit 8529017 into iluwatar:master May 15, 2025
2 checks passed
@iluwatar
Copy link
Owner

Looks good! Thank you for the contribution 🎉

@all-contributors please add @yybmion for code

@allcontributors
Copy link
Contributor

@iluwatar

I've put up a pull request to add @yybmion! 🎉

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

Labels

None yet

3 participants