source: class Primes {
  
      public final int compute() {
          long start = System.currentTimeMillis();
          int cnt = 0;
          int prntCnt = 97;
          int res;
          for (;;) {
              res = next();
              cnt += 1;
              if (cnt % prntCnt == 0) {
                  log("Computed " + cnt + " primes in " + (System.currentTimeMillis() - start) + " ms. Last one is " + res);
                  prntCnt *= 2;
              }
              if (cnt >= 100000) {
                  break;
              }
          }
          return res;
      }
  
      protected  Primes();
  
       int next();
      protected abstract void log(String msg);
      public static void main(String... args);
  
  }
  
  class PrimesTest {
  
      @Test
      public void fifthThousandThPrime() {
  
target:         Primes p = new Primes() {
              @Override
              protected void log(String msg) {
              }
          };
          int last = p.compute();
          assertEquals("100000th prime is", 1_299_709, last);
      }
  
  }