private void run() { try { while (true) { Connection conn = (Connection) connectQueue.dequeue(); parent.addConnection(conn.connect()); } } catch (EndOfQueueException e) {} synchronized (this) { done = true; notifyAll(); while (!exit) { try { wait(); } catch (InterruptedException x) {} } } }
/** * Connect to the given address. This method is called by a {@link * Supervisor} object. * * @return the new connection * @param owner the one calling this method * @param spec the address to connect to * @param context application context for the new connection * @param sync perform a synchronous connect in the calling thread * if this flag is set */ Connection connect(Supervisor owner, Spec spec, Object context, boolean sync) { Connection conn = new Connection(this, owner, spec, context); if (sync) { addConnection(conn.connect()); } else { connector.connectLater(conn); } return conn; }