@ Override public Object get ( ) { Object oObject = null ; synchronized ( this ) { // Check if any are free in the free hashtable if ( lastEntry > - 1 ) { // Free array has entries, get the last one. // remove last one for best performance oObject = free [ lastEntry ] ; free [ lastEntry ] = null ; if ( lastEntry == firstEntry ) { // none left in pool lastEntry = - 1 ; firstEntry = - 1 ; } else if ( lastEntry > 0 ) { lastEntry = lastEntry - 1 ; } else { // last entry = 0, reset to end of list lastEntry = poolSize - 1 ; } } } if ( oObject == null && factory != null ) { oObject = factory . create ( ) ; } return oObject ; }
Gets an Object from the pool and returns it . If there are currently no entries in the pool then a new object will be created .