File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Threads and Synchronization and the fly likes MultiThreading in java working in MultiProcessor Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of RabbitMQ in Depth this week in the Open Source forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "MultiThreading in java working in MultiProcessor" Watch "MultiThreading in java working in MultiProcessor" New topic

MultiThreading in java working in MultiProcessor

Yugandhar Reddy

Joined: Jun 10, 2002
Posts: 2
I have an application written in java
I am creating a pool of threads and executing a process on each thread.
If i create a single thread on single processor system and give the process on it, it is taking 30 sec.
if i create two threads on dual processor system and giving the process on each thread, it is taking 54 sec.
I want to know how the dual processor system works in case of multi threading.
Thanks for the help.

Dan Cranmer

Joined: May 24, 2000
Posts: 24
It might have to do with the platform and JVM you are using. I ran the following code on a 3 processor Sun, when only one thread is created I can only use 33.3% of the CPU, when 2 threads are created it starts to use 66.6% and when all 3 threads are started I use all available processors.
Mr. C Lamont Gilbert
Ranch Hand

Joined: Oct 05, 2001
Posts: 1170

Can your process be easily divided? some processes do not lend themselves to speed-ups due to multithreading.
I agree. Here's the link:
subject: MultiThreading in java working in MultiProcessor