Solved

Set the number of processors java uses

Posted on 2004-03-24
6
690 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
mergeTwo  challenge 13 72
count11 challenge 6 47
parentbit challenge 3 52
word0 challenge 4 53
For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

706 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

18 Experts available now in Live!

Get 1:1 Help Now