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?
|
|