Example #1
0
  public void run() {
    Thread run_thread = Thread.currentThread();
    Exception ex0 = null;

    try {
      /* We cannot synchronize (run_thread) here or the caller's
       * thread.wait( timeout ) cannot reaquire the lock and
       * return which would render the timeout effectively useless.
       */
      doConnect();
    } catch (Exception ex) {
      ex0 = ex; // Defer to below where we're locked
      return;
    } finally {
      synchronized (run_thread) {
        if (run_thread != thread) {
          /* Thread no longer the one setup for this transport --
           * doConnect returned too late, just ignore.
           */
          if (ex0 != null) {
            ex0.printStackTrace();
          }
          return;
        }
        if (ex0 != null) {
          te = new TransportException(ex0);
        }
        state = 2; // run connected
        run_thread.notify();
      }
    }

    /* Proccess responses
     */
    loop();
  }
Example #2
0
 private void proceedSendFile() {
   synchronized (sendThread) {
     display("pushed proceed !");
     sendThread.notify();
   }
 }