Solved

Set the number of processors java uses

Posted on 2004-03-24
6
693 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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
difference of if loops 23 50
servlet example issue 6 40
servlet example 11 40
hibernate insert example 13 29
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …

831 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