In this assignment, you are given three introductory exercises focused on the basics of multithreading. Solve each exercise according to the provided guidelines.
- Review the concepts of multithreaded programming and utilize them correctly
- Review the different methods of creating threads in java
- Utilize interrupts and debug a program using them
- Familiarize yourself with Thread Pools
- Write a report on the assignment
-
Fork this repository and clone the fork to your local machine. Ensure to create a new Git branch before starting your work
-
Complete the following exercises based on the instructions provided:
CPU Simulator
: Simulate a single core CPU and schedule tasks to run on a threadFind Multiples
: write a multithreaded program to find all integers in a given range that are divisible by 3, 5, or 7. Return the sum of all unique integers.Use Interrupts
: Analyze the provided code and add interrupts where a thread must be terminated. Handle each interrupt in its respective thread.
-
Commit your changes and push your commits to your fork on Github. Create a pull request (assigned to your mentor) to merge your changes to the main branch of your fork on Github.
- You can find unit tests for the first two exercises (
CPU Simulator
andFind Multiples
). Use these to ensure you've implemented the code correctly. - You are not allowed to change or delete any existing line of code in the third exercise (
Use Interrupts
). You can only add new code to solve the issues presented in the exercise. - Your report should focus on the solution you choose for each exercise (and why you chose it). Include any multithreading principles that you used in your report.
- Your code should compile and run without any errors
- Your code should be well-organized, readable, properly commented and should follow clean code principles
- Your code should pass all of the provided unit tests
- You should use Git for version control and include meaningful commit messages
- Expand the
CPU Simulator
exercise by simulating a dual core CPU. Create a separate file for the new simulation. Include details of your implementation in your report. - Learn how to use Thread Pools in Java and solve the
Find Multiples
problem using a Fixed or Cached Thread Pool. Provide adequate explanation regarding Thread Pools and the difference between using a Thread Pool and other thread creation methods.
- Push your code to your fork on Github
- Upload your report to your fork on GitHub
The deadline for submitting your code is Wednesday, May 3 (13th of Ordibehesht). Good luck, happy coding and hasta luego!