August 2011
Intermediate to advanced
280 pages
6h 50m
English
The number of cores has a greater influence on the speedup of computation-intensive applications than on IO-bound applications, as we’ll see in this section. The example we’ll use is very simple; however, it has a hidden surprise—the uneven workload will affect the speedup.
Let’s write a program to compute the number of primes between 1 and 10 million. Let’s first solve this sequentially, and then we’ll solve it concurrently.
Let’s start with the abstract class AbstractPrimeFinder, which will help group some common methods for the problem at hand. The isPrime method will tell whether a given number is prime, and the countPrimesInRange method uses it to count ...
Read now
Unlock full access