synchronized( this ){ if ( !sleeping ){ wakeup_outstanding = true; }else{ this.notify(); } }
synchronized( this ){ if ( wakeup_outstanding ){ wakeup_outstanding = false; return( false ); } try{ sleeping = true; this.wait( timeout ); }catch( Throwable e ){ Debug.printStackTrace( e ); }finally{ sleeping = false; } return( true ); }