The Runtime class has an availableProcessors method that returns the number of processors available to the JVM.
int processors = Runtime.getRuntime().availableProcessors();
The value may change during the execution of your application, so poll regularly if your application is dependant on the number of processors available.
Leave a Reply
You must be logged in to post a comment.