ajithganesan
ajithganesan

Reputation: 11

Java Single Process with Multiple Threads

Since JVM creates only one process initially, does creating multiple threads in this process boost CPU performance assuming you have multiple CPU processors? This is because since all the threads inside the same process share the resources of the process. So, technically the execution is sequential?

In other words, unless you create two or more processes and associate threads to each of them, you cant avail the full benefit of parallel execution in multiple CPU processors?

Upvotes: 1

Views: 646

Answers (1)

Konrad Höffner
Konrad Höffner

Reputation: 12207

Yes, distributing the workload over multiple threads can boost the performance of your program. It also increases the responsiveness.

However there is an increased overhead due to communication and synchronization. Also, not all algorithms are able to be parallelized.

Upvotes: 2

Related Questions