Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gervinfung/simpleparalleldispatcher
Simple Basic Parallel Program. A Java program that use thread and semaphore to simulate Dispatcher and Sorter
https://github.com/gervinfung/simpleparalleldispatcher
multithreaded multithreading
Last synced: 12 days ago
JSON representation
Simple Basic Parallel Program. A Java program that use thread and semaphore to simulate Dispatcher and Sorter
- Host: GitHub
- URL: https://github.com/gervinfung/simpleparalleldispatcher
- Owner: GervinFung
- Created: 2020-11-04T10:13:53.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2021-11-07T09:39:30.000Z (about 3 years ago)
- Last Synced: 2024-10-04T16:22:31.873Z (3 months ago)
- Topics: multithreaded, multithreading
- Language: Java
- Homepage:
- Size: 42 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Write a multithreaded program to simulate the operations of Sorter, Dispatcher A and Dispatcher B in the scenario based on the following guidelines:
1. Sorter, Dispatcher A and Dispatcher B are handled by a separate thread.
2. An additional thread is used to simulate the arrival of item. This thread will generate an item
randomly (item A or B) at a random interval. (Use an appropriate interval range based on your
system so that the program will not execute too fast, and you cannot monitor the output)
3. Each storage bag can store 10 items and there is unlimited supply of storage bag.
Sorter will wait for the arrival of item and then put it in to the storage bag accordingly. Item
will arrive at a random interval.
4. Dispatcher will wait until the bag is full before it moves it to the conveyor. It will then wait for
the next bag to be loaded.
5. Each thread should print a message to indicate its current operation. Examples:
o Sorter may print messages such as| Process |
| :--- |
|1. Sorter: To bag B|
|2. Sorter: waiting item...|
|3. Sorter: To bag A (9)|
|4. Sorter: waiting item...|
|5. Sorter: To bag A (10)|
|6. Sorter: Bag A full|
|7. Sorter: waiting item...||Thread that simulates arrival of item may print messages such as|
| :--- |
|1. Arrival: Item A|
|2. Arrival: Item A|
|3. Arrival: Item B|Note: the output from each thread may interleave.
1. All threads should run iteratively.
2. The program should be properly commented and meaningful name should be used for any
variable, function or method.