Query host for the number of processors

When deciding on an execution policy for your multi-threaded tasks, you sometimes need to decide how many threads to use. Often, you may want to base this upon the number of processors available.

Instead of hard-coding such values, you should likely query the host for the number of available processors, using

Runtime.getRuntime().availableProcessors();

Would you use this technique?
Yes   No   Undecided   
© 2014 Hirondelle Systems | Source Code | Contact | License | RSS
Individual code snippets can be used under this BSD license - Last updated on September 21, 2013.
Over 2,000,000 unique IPs last year - Built with WEB4J.
- In Memoriam : Bill Dirani -