import Utilities.*; import Synchronization.*; class Nqueens extends MyObject implements Runnable { private static int N = 8; private static int NCPU = 4; private static int numSolutions = 0; private static PipedMessagePassing getWork = null; private static PipedMessagePassing putCount = null; private int id = -1; private Nqueens(int id) { super("Worker" + id); this.id = id; new Thread(this).start(); } public void run() { while (true) { int inRow = receiveInt(getWork); System.out.println("age()=" + age() + ", " + getName() + " counting solutions with column 1 queen in row " + inRow); int[] board = new int[N+1]; // need 1 through N (0 unused) for (int i = 0; i < board.length; i++) board[i] = 0; board[1] = inRow; int numFound = place(2, board); send(putCount, numFound); System.out.println ("age()=" + age() + " Solutions with column 1 queen in row " + inRow + " = " + numFound); } } private static boolean safe(int row, int column, int[] board) { for (int j=1; j