Queens solution = new Queens(this, r, c);
int nextRow = r+1;
Join join = new Join();
Iterator e = PE.roundRobin();
for (int i = 0; i < N; i++) {
if (solution.col[i] && solution.getLeftDiag(nextRow, i)
&& solution.getRightDiag(nextRow, i)) {
solution.row[nextRow] = i;
if (nextRow == N-1) {
System.out.println(solution);
return; // no other solutions possible
} else { // fork and return
Worker worker = new Worker(solution, nextRow, i, depth-1);
worker.start((PE) e.next(), join);
}
}
}
join.waitFor();
}