aspose file tools
The moose likes Java in General and the fly likes References for threading and multi-core cpus Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "References for threading and multi-core cpus" Watch "References for threading and multi-core cpus" New topic
Author

References for threading and multi-core cpus

Stephen Upton
Greenhorn

Joined: Dec 26, 2005
Posts: 9
Hi all,

I'm looking for any good reference material on programming in java on multi-core machines. I'm looking for ways to query the number of cores on a machine, so that I may then tailor the number of threads I generate or alternatively, just starting different jvm's, since the threads/jvm will be independent jobs. Any hints on best practice on this would be welcome as well.

thanks!
steve
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 16684
    
  19

I'm looking for ways to query the number of cores on a machine, so that I may then tailor the number of threads ....


Take a look at the availableProcessors() method of the Runtime class.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Stephen Upton
Greenhorn

Joined: Dec 26, 2005
Posts: 9
Thanks Henry! That helps on the second part. I have your book on Java Threads, which helps with the first part. I'm now curious as to best practices or ideas on figuring out whether it's best just to start a new jvm or start a thread for my compute task (the one I'm using the jvm or thread for).

thanks!
steve
Bill Shirley
Ranch Hand

Joined: Nov 08, 2007
Posts: 457
I would say there's no reason not to spawn a new thread (regardless of the executing architecture) as long as the count stays under something reasonable.

(Your definition of reasonable may vary from the next guy's)


Bill Shirley - bshirley - frazerbilt.com
if (Posts < 30) you.read( JavaRanchFAQ);
 
I agree. Here's the link: http://zeroturnaround.com/jrebel
 
subject: References for threading and multi-core cpus
 
Similar Threads
Log4j. Worker threads logging to seperate files
Thread question
MaximumThroughput- MltiThreading - Need help
multithreading in single cpu
Thread Pooling