public void drain ( ) { synchronized ( list ) { for ( int i = 0 ; i < list . size ( ) ; ++ i ) { Pooled < T > pt = list . remove ( ) ; creator . destroy ( pt . content ) ; pt . logTarget . log ( "Pool drained " , creator . toString ( ) ) ; } count = spares = 0 ; } }
Destroy and remove all remaining objects . This is valuable for closing down all Allocated objects cleanly for exiting . It is also a good method for removing objects when for instance all Objects are invalid because of broken connections etc .