-
Notifications
You must be signed in to change notification settings - Fork 0
W11: Home Study
Atanbori edited this page Jan 15, 2025
·
2 revisions
Instruction:
- Implement a function
calculateFactorial()
that takes an integer as input and calculates its factorial recursively. - Divide the workload of calculating the factorial across multiple threads to make use of parallelism, by using the method
calculatePartialFactorial()
. - Create multiple threads, each responsible for calculating the factorial of a subset of the number's range.
- In the
calculateFactorial()
function, join the threads and collect the results.
By implementing this task, you will gain hands-on experience in the following multi-threading concepts:
- Creating and managing threads.
- Dividing workload across multiple threads.
- Synchronization and thread safety (to avoid race conditions).
- Joining threads and collecting results.
Instructions:
- Create functions to initialize the matrices with random values and display them.
- Implement a function
multiplyMatrices()
that performs matrix multiplication. - Divide the workload of matrix multiplication across multiple threads to achieve parallelism, by using the method
multiplyMatricesPart()
. - In
multiplyMatrices()
, create multiple threads, each responsible for calculating a subset of the resulting matrix. - Don't forget to join the threads and collect the results.