@Override
  public void run() {
    long paths = 0;
    while (!doneWalking) {
      Path path = walkPath();
      paths++;

      // Check with atomic integer so no context switch required
      if (path.size() > maxLength.get()) {
        System.out.println(path.size());
        writeResult(path);
      }

      if (paths % 10000 == 0) {
        System.out.println("Paths walked: " + paths);
      }
    }
  }