This exercise involves running a program that uses numerical integration to calculate the elapsed time taken by a program using one processor versus several threads. The goal of the exercise is to compare the performance of a single-threaded program with a multithreaded program and analyze the impact of using multiple threads on the elapsed time and CPU usage. The results are shown below
NumInt.java file is compiled using the javac command.
javac NumInt.java
Elapsed time is noted after running the java command.
java NumInt
CPU usage is observed via the Task Manager
Noting the elapsed time, we compared the NumInt.java program with the multithreaded version (NumIntThreaded.java).
Compiled and ran the multithreaded program multiple times with a varying number of threads that matched the number of processors, while noting the elapsed time and CPU usage.
Created a graph to visualize the relationship between the number of threads and elapsed time.
As observed in the graph, the elapsed time decreases as the number of threads increases, indicating that the application is benefiting from parallelization and efficiently utilizing the available resources. The burden is distributed among numerous threads as the number of threads increases, allowing them to perform concurrently and potentially reducing overall execution time.


