Description
The following workshop lets you practice basic java coding techniques, creating classes, methods, using arrays, Java I/O, inheritance, polymorphism, Exceptional Handling, JavaFx (GUI), Lambda expressions, Functional Interface, Collection Framework, Java Threads. Task 1: In this task you will be experiencing on how to perform matrix multiplication. • Suppose you have multiple processors, so you can speed up the matrix multiplication. • You must implement the following method in parallel. public static double[][] parallelMultiplyMatrix(double[][] a, double[][] b) • Second must implemented method should be a normal sequential process public static double[][] sequentialMultiplyMatrix(double[][] c, double[][] d) • Write a test program that measures the execution time for multiplying two 2,000 * 2,000 matrices using the parallel method (by running the multiple threads). • Also calculate the execution time for adding two 2,000 * 2,000 matrices using the sequential method (calling the method as normal call). Hint: For parallel addition divide your matrix in to 4 matrices for example the size of 2000 * 2000 can be divided into [0][500], [501] [1000],[1001][1500],[1501][2000] then run the addition of all in 4 different threads and at the end join the threads to finish the process one after another and calculate the time of all the threads. You can use the examples from the slides on how to calculate time for threads (week 9 lecture slides). Note: Students are supposed to design their own output for the task Continue to the next page… JAC – 444 Semester 2021 Task 2: Problem Description: There are five philosophers sitting at a round table. There is one chopstick between the two people. There is noodles in the center of the table. The philosopher thinks about the problem. When he is hungry, he picks up two chopsticks and eats two chopsticks. He must get two chopsticks to eat. The above problem will lead to a deadlock situation. When five philosophers pick up the chopsticks on their right-hand side and prepare to take the chopsticks on the lefthand side, they will be deadlocked. There can be multiple possible solution to this situation, two of them are presented Solution 1: Add a waiter. Only when the waiter agrees can you take chopsticks. The waiter is responsible for avoiding deadlocks. Solution 2: Each philosopher must determine that the chopsticks of his left and right hands are available, can pick up two chopsticks at the same time to eat, and put down two chopsticks at the same time after eating. Your task is to choose one of the solutions and program it is using the threads to avoid the dead lock. Note: Students are supposed to design their own output for the task JAC – 444 Semester 2021 Workshop Header /********************************************** Workshop # Course: – Semester Last Name: First Name: ID: Section: