public void waitUntilConnectionReleasedIfNecessary ( ) throws InterruptedException { if ( ConnectionStatus . RUNNING == status . get ( ) || ConnectionStatus . TERMINATED == status . get ( ) ) { while ( ! status . compareAndSet ( ConnectionStatus . RELEASE , ConnectionStatus . RUNNING ) ) { resourceSynchronizer . doAwaitUntil ( ) ; } } }
Wait until connection is released if necessary .