Java:
public class ProcessorCounter {
public static void main(String[] args) {
int processorsCount = Runtime.getRuntime().availableProcessors();
System.out.println("The number of available processors is:" + Integer.toString(processorsCount));
}
}
Clojure:
(let [runtime (Runtime/getRuntime)
processors-count (.availableProcessors runtime)]
(println "The number of available processors is: " (str processors-count)))
Limits to parallelism:There are two limits to parallelism:
- The number of available processors, which is determined by the available processors method.
- The overhead of threading, which states that sometimes the cost of launching parts of a computation into separate threads can outweigh the advantages of parallelism.
No comments:
Post a Comment