April 2017
Intermediate to advanced
594 pages
25h 15m
English
Follow these steps to implement the example:
public class Calculator implements Runnable {
@Override public void run() { long current = 1L; long max = 20000L; long numPrimes = 0L; System.out.printf("Thread '%s': START\n", Thread.currentThread().getName()); while (current <= max) { if (isPrime(current)) { numPrimes++; } current++; } System.out.printf("Thread '%s': END. Number of Primes: %d\n", Thread.currentThread().getName(), numPrimes); }
Read now
Unlock full access