@ Override public void run ( ) { final boolean isTracingEnabled = TraceComponent . isAnyTracingEnabled ( ) ; if ( isTracingEnabled && tc . isEntryEnabled ( ) ) { Tr . entry ( this , tc , "run" , "alarm" ) ; } if ( isTracingEnabled && tc . isDebugEnabled ( ) ) { Tr . debug ( this , tc , "run: alarm, Pool contents ==> " + this . toString ( ) ) ; Tr . debug ( this , tc , "reaperThreadStarted: " , reaperThreadStarted ) ; } if ( needToReclaimConnections ( ) || needToReclaimTLSConnections ( ) ) { // Create thread to reclaim connections startReclaimConnectionThread ( ) ; } if ( isTracingEnabled && tc . isDebugEnabled ( ) ) { Tr . debug ( this , tc , "run: alarm, Pool contents ==> " + this . toString ( ) ) ; Tr . debug ( this , tc , "reaperThreadStarted: " , reaperThreadStarted ) ; } synchronized ( amLockObject ) { if ( this . agedTimeout < 1 ) { if ( ( totalConnectionCount . get ( ) > minConnections ) && alarmThreadCounter . get ( ) >= 0 ) { createReaperAlarm ( ) ; } else { if ( alarmThreadCounter . get ( ) > 0 ) alarmThreadCounter . decrementAndGet ( ) ; if ( isTracingEnabled && tc . isDebugEnabled ( ) ) Tr . debug ( tc , "Alarm thread was NOT started. Number of alarm threads is " + alarmThreadCounter . get ( ) ) ; } } else { if ( totalConnectionCount . get ( ) > 0 && alarmThreadCounter . get ( ) >= 0 ) { createReaperAlarm ( ) ; } else { if ( alarmThreadCounter . get ( ) > 0 ) alarmThreadCounter . decrementAndGet ( ) ; if ( isTracingEnabled && tc . isDebugEnabled ( ) ) Tr . debug ( tc , "Alarm thread was NOT started. Number of alarm threads is " + alarmThreadCounter . get ( ) ) ; } } } if ( isTracingEnabled && tc . isEntryEnabled ( ) ) { Tr . exit ( this , tc , "run" ) ; } }
This method can be submitted to a ScheduledExecutorService to run in the future .