ningboliu commented on issue #12117: URL: https://github.com/apache/dubbo/issues/12117#issuecomment-1516457823
Because the bound of pos2 is ( length - 1 ), in order to ensure the balance as much as possible, it should add 1 if pos2 is greater than or equal to pos1 , otherwise it will never get the last invoker. This is an alternative to `while ( pos1 != (pos2 = ThreadLocalRandom.current().nextInt( length - 1))) { break; }` , and the performance is generally better I don't know if I made it clearly @AlbumenJ @MangerLe -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@dubbo.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@dubbo.apache.org For additional commands, e-mail: notifications-h...@dubbo.apache.org