private void addConnectionRequest ( ) { if ( totalConnection . get ( ) < options . maxPoolSize && poolState . get ( ) == POOL_STATE_OK ) { //ensure to have one worker if was timeout connectionAppender . prestartCoreThread ( ) ; connectionAppenderQueue . offer ( ( ) -> { if ( ( totalConnection . get ( ) < options . minPoolSize || pendingRequestNumber . get ( ) > 0 ) && totalConnection . get ( ) < options . maxPoolSize ) { try { addConnection ( ) ; } catch ( SQLException sqle ) { //eat } } } ) ; } }
Add new connection if needed . Only one thread create new connection so new connection request will wait to newly created connection or for a released connection .