public final Object removeOne ( ) { // Avoid locking the whole Map by looking at the subMaps indivdually starting at a // random point in the sequence. int index = new java . util . Random ( Thread . currentThread ( ) . hashCode ( ) ) . nextInt ( subMaps . length ) ; int firstIndex = index ; Object removedObject = null ; do { java . util . Map subMap = subMaps [ index ] ; synchronized ( subMap ) { if ( ! subMap . isEmpty ( ) ) { java . util . Iterator iterator = subMap . values ( ) . iterator ( ) ; removedObject = iterator . next ( ) ; iterator . remove ( ) ; break ; } // if (freeTransactions.isEmpty()). } // synchronized (subMap). index ++ ; if ( index == subMaps . length ) index = 0 ; } while ( index != firstIndex ) ; return removedObject ; }
Remove any singe element from the map .