while (System.currentTimeMillis() - t0 < timeout) { m_Mutex.wait(5); if (!isCurrentlyOwned()) break; if (isCurrentlyOwned()) throw new PortInUseException();
while (System.currentTimeMillis() - t0 < timeout) { m_Mutex.wait(5); if (!isCurrentlyOwned()) break; if (isCurrentlyOwned()) throw new PortInUseException(getCurrentOwner());
while (System.currentTimeMillis() - t0 < timeout) { m_Mutex.wait(5); if (!isCurrentlyOwned()) break; if (isCurrentlyOwned()) throw new PortInUseException(getCurrentOwner());
/** * Returns the serial port instance. * * @param aOptions * the serial port options, cannot be <code>null</code>. * @return the serial port instance, never <code>null</code>. * @throws NoSuchPortException * in case the desired port does not exist; * @throws PortInUseException * in case the desired port is already in use; * @throws IOException * in case of other I/O problems. */ private SerialPort getSerialPort( final CommPortOptions aOptions ) throws NoSuchPortException, PortInUseException, IOException { final CommPortIdentifier commPortId = CommPortIdentifier.getPortIdentifier( aOptions.getPortName() ); if ( commPortId.isCurrentlyOwned() && ( commPortId.getCurrentOwner() != CONNECT_ID ) ) { throw new PortInUseException(); } final CommPort commPort = commPortId.open( CONNECT_ID, 2000 ); if ( !( commPort instanceof SerialPort ) ) { throw new IOException( "Not a serial port?!" ); } return ( SerialPort )commPort; }