Solved

Set the number of processors java uses

Posted on 2004-03-24
6
692 Views
Last Modified: 2008-03-06
I just upgraded my machine to a 3Ghz pentium 4 with hyper-threading.  It shows up to the os as 2 logical processors.  When I run any java program, it doesn't seem to take advantage of this - my cpu consumption never exceeds 50%.

Is there some way I can tell java how many processors I have?

Thanks,

Shawn
0
Comment
Question by:ShawnCurry
6 Comments
 
LVL 92

Expert Comment

by:objects
ID: 10674082
not that i am aware of
0
 
LVL 92

Assisted Solution

by:objects
objects earned 125 total points
ID: 10674087
see if anything in here helps:
http://java.sun.com/docs/performance/
0
 
LVL 9

Assisted Solution

by:mmuruganandam
mmuruganandam earned 125 total points
ID: 10674508
It is purely OS dependent.  The JVM is being loaded and handled by the OS.  The thread scheduling within the JVM would happen based on how the JVM process between CPU's


Regards,
Muruga
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 1

Accepted Solution

by:
solnpro earned 250 total points
ID: 10679909
There is a really good article called Hyper-Threading Java in the August 2003 Java Developer's Journal or online at http://www.sys-con.com/story/?storyid=37663 if you are a subscriber.  It also includes benchmarking source code.

Some of the questions this article would have me raise are:

Are you running on a supported OS?  See http://www.intel.com/support/platform/ht/os.htm?iid=ipp_htm+os&

Was your application single or multi-threaded?  (Single-threaded applications will see little improvement.)

If you were multi-threading, were your threads performing different operations?  (Multi-threaded applications with threads performing the same tasks on one physical CPU will see little improvement.)

<Solnpro>
0
 
LVL 3

Author Comment

by:ShawnCurry
ID: 10696771
The application satisfies all the above.  I am running xp pro.  My app has a total of 3 thread pools, currently two run 4 worker threads, and the other runs two threads; also I have several random threads running tasks in the gui (though I plan to consolidate these).

The first 2 pools (for a total of 8 threads) deal only with communicating with a cgi script (waiting for the server response).  The other pool (two threads) process the responses.

I've figured out why it was chewing up so much processor on my 3ghz.. which leads (indirectly) to my next question..

I'll leave this open for a few more days; since it doesn't seem to be something I can set in java; maybe someone has another idea??

Thanks,
Shawn
0
 
LVL 92

Expert Comment

by:objects
ID: 10702588
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now