question: public void waitForReady ( long how_long ) throws IOException { long since = System . currentTimeMillis ( ) ; synchronized ( state_mutex ) { while ( true ) { if ( state == State . DEMO ) { return ; } else if ( state == State . ERROR || state == State . DISCONNECTED ) { throw new IOException ( "Connection Error" ) ; } else if ( ( System . currentTimeMillis ( ) - since ) >= how_long ) { try { disconnect ( ) ; } catch ( IOException e ) { } throw new IOException ( "Timeout connecting to ARDrone" ) ; } long p = Math . min ( how_long - ( System . currentTimeMillis ( ) - since ) , how_long ) ; if ( p > 0 ) { try { state_mutex . wait ( p ) ; } catch ( InterruptedException e ) { } } } } }
target:  Wait for drone to switch to demo mode. Throw exception if this not succeeded within given timeout. Should be called right after connect(). This is a convenience function. Another way to achieve the same result is using status change callback.