Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sueszli/concurrent-elevators
elevators concurrency problem in java
https://github.com/sueszli/concurrent-elevators
concurrent-programming modern-java
Last synced: 20 days ago
JSON representation
elevators concurrency problem in java
- Host: GitHub
- URL: https://github.com/sueszli/concurrent-elevators
- Owner: sueszli
- License: mit
- Created: 2023-01-18T16:34:57.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-04-25T00:45:42.000Z (7 months ago)
- Last Synced: 2024-10-05T23:21:30.047Z (about 1 month ago)
- Topics: concurrent-programming, modern-java
- Language: Java
- Homepage:
- Size: 490 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
A super minimal implementation of a thread-pool-executor service / scheduler in Java. The goal is to provide a simple,
easy to understand implementation. The implementation is not intended to be used in production, but rather to be used as
a learning tool.## Problem
- There are 7 elevators in a building with 55 floors.
- Each floor has exactly one button to request an elevator.- Elevators have the capacity of carrying an arbitrary, given number of people.
- Elevators don't change direction and don't stop mid-trip.- People can only choose their destination freely, when they are on the ground-floor:
- up: ground-floor [0] − can only travel to ⟶ non-ground-floor [1;54]
- down: non-ground-floor [1;54] − can only travel to ⟶ ground-floor [0]- The requests are handled globally.
- The elevator-scheduler assigns a chosen request to an elevator based on some arbitrary algorithm.
- If there are no elevators available, the request is queued up.## Design decisions
- Decided to use vanilla Java without any non-default libraries for the sake of simplicity.
- Got rid of the suggested "up"/"down" directions since they can be inferred from the current floor.
- Chose a poison-pill approach to terminate the scheduler (also
see: [this similar implementation](https://gitlab.com/niklaswimmer/dc-tower-elevator-challange/-/blob/main/app/src/main/java/me/nikx/dctower/TowerController.java))
- Chose JDK-19 to make use of type inferrence with `var` and other nifty features.