Skip to content

oriyomibadmus/Multithreading-in-Java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Multithreading-in-Java

Performance Comparison Of A Single-Threaded Program With A Multithreaded Program

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

Steps Taken

Step 1

NumInt.java file is compiled using the javac command.

javac NumInt.java

javac

Step 2

Elapsed time is noted after running the java command.

java NumInt

Step 3

CPU usage is observed via the Task Manager

CPU usage

Step 4

Noting the elapsed time, we compared the NumInt.java program with the multithreaded version (NumIntThreaded.java).

Step 5

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.

number of threads

Step 6

Created a graph to visualize the relationship between the number of threads and elapsed time.

Graph

Screenshot

Discussion About The Observed 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.

About

Performance Comparison Of A Single-Threaded Program With A Multithreaded Program

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages