Ejemplo n.º 1
0
 void solve() {
   Thread tcThread = new Thread(tc);
   // System.out.println("starting client thread");
   tcThread.start();
   try {
     tcThread.join();
   } catch (Exception e) {
     e.printStackTrace();
   }
   // System.out.println("joined client thread");
   result = SudokuSolver.solve(tc.testcase);
   success = SudokuSolver.isLegalSolution(result, tc.testcase);
 }
Ejemplo n.º 2
0
 public void run() {
   System.out.println("starting " + threadname + " run method on port " + SudokuServer.PORT);
   System.out.flush();
   try {
     Socket sock = new Socket(hostname, SudokuServer.PORT);
     PrintWriter dos = new PrintWriter(sock.getOutputStream());
     BufferedReader dis = new BufferedReader(new InputStreamReader(sock.getInputStream()));
     dos.println(testcase);
     dos.flush();
     String response = dis.readLine();
     System.out.println(
         "Client " + threadname + " sent: " + testcase + " received response:" + response);
     dos.close();
     dis.close();
     synchronized (sc) {
       sc.result = response;
     }
   } catch (Exception e) {
     e.printStackTrace();
   }
   System.out.println("finishing " + threadname + " run method");
 }