public synchronized Hosts putAllInRandomOrder ( String domain , String [ ] ips ) { Random random = new Random ( ) ; int index = ( int ) ( random . nextLong ( ) % ips . length ) ; if ( index < 0 ) { index += ips . length ; } LinkedList < String > ipList = new LinkedList < String > ( ) ; for ( int i = 0 ; i < ips . length ; i ++ ) { ipList . add ( ips [ ( i + index ) % ips . length ] ) ; } hosts . put ( domain , ipList ) ; return this ; }
avoid many server visit first ip in same time . s