public static < R > R suspendWhenNull ( long intervalAsMillis , Supplier < R > objectSupplier ) { R object = objectSupplier . get ( ) ; if ( object == null ) { log . warn ( "Start Suspending !!!" ) ; long startTimeMillis = System . currentTimeMillis ( ) ; while ( ( object = objectSupplier . get ( ) ) == null ) sleep ( intervalAsMillis ) ; log . warn ( "Stop Suspending Over {} ms" , System . currentTimeMillis ( ) - startTimeMillis ) ; } return object ; }
Suspend when null r .