public static void main(String[] args) {
    System.out.println("Starting");
    CycAccess access = null;
    try {
      access = new CycAccess("localhost", 3660);
      String query = "(#$isa ?X #$Dog)";
      InferenceWorkerSynch worker = new DefaultInferenceWorkerSynch(query, 
        CycAccess.inferencePSC, null, access, 500000);
      InferenceResultSet rs = worker.executeQuery();
      try {
        int indexOfX = rs.findColumn("?X");
        while (rs.next()) {
          CycObject curDog = rs.getCycObject(indexOfX);
          System.out.println("Got dog: " + curDog.cyclify());
        }
        System.out.flush();
      } finally {
        rs.close();
      }
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      if (access != null) {
        access.close();
      }
    }
    System.out.println("Finished");
    System.exit(0);
  }