Question: Please write in Java. Thank you. :D 6.1 During class time, we mention that there are two types of parallelism: Data parallelism and task parallelism.
Please write in Java. Thank you. :D
6.1 During class time, we mention that there are two types of parallelism: Data parallelism and task parallelism. In lab 6.1, you need to write two multithreaded programs in Java to simulate these two types of parallelism.
Assume we have a dataset including integers from 1 to 299. For Data parallelism, please write a multithreaded program and do the following three tasks in parallel.
Task 1: calculate the sum of integers from 1 to 99;
Task 2: calculate the sum of integers from 100 to 199;
Task 3: calculate the sum of integers from 200 to 299; For each task, please print the result on screen finally.
For Task parallelism, please write a multithreaded program and do the following three tasks in parallel.
Task 1: calculate the sum of all integers in the dataset;
Task 2: calculate the mean value of all integers in the dataset;
Task 3: calculate the sum of the squares of every integer in the dataset, the result should be the value equal to 1^2+2^2+3^2+...+299^2.
For each task, please print the result on screen finally.
6.2 In this practice, please use the thread pool to execute the tasks for either Data parallelism or task parallelism in Lab 6.1. And all threads used for executing the tasks should be the existing threads in the pool instead of creating them.
Please note, you dont need to do both data parallelism and task parallelism in Lab 6.2, pick one to practice how to use thread pool in Java.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
