Esempio n. 1
0
  public static boolean waitForService(int port) {
    final int MAX_TRY_COUNT = 10;
    int tryCount = 0;
    while (true) {
      if (isPortOccupied(port)) {
        return true;
      }

      if (tryCount == MAX_TRY_COUNT) {
        System.err.println("Waiting for port " + port + " time out.");
        return false;
      }
      try {
        Thread.sleep(1000);
      } catch (InterruptedException e) {
        // ignore
      }
      tryCount++;
    }
  }
Esempio n. 2
0
 /** wait for the thread to finish */
 public void join() throws InterruptedException {
   sucker.join();
 }
Esempio n. 3
0
 public void start() {
   sucker = new Thread(this);
   sucker.start();
 }