ratelimiter 2020-10-25 LanguageJavaGrava nexthexonextbutterflyvolantisyearnyiliashokaindigoapollolandscapecactusmateryicarusfluidmaterial GuavaRateLimiter1234567891011121314151617RateLimiter rateLimiter = RateLimiter.create(10);for (int i = 0; i < 20; i++) { int finalI = i; new Thread(new Runnable() { @Override public void run() { int cnt = 0; while (true) { if (rateLimiter.tryAcquire()) { cnt++; System.out.println("thread: " + finalI + " cnt: " + cnt); } } } }).start();}Thread.sleep(1000 * 100 * 1000); 源码流程图: 最后更新时间:2020-10-25 00:00:00 这里可以写作者留言,标签和 hexo 中所有变量及辅助函数等均可调用,示例:<%- page.permalink.replace(/index\.html$/, '') %> 赏 Prev webFlux Next 深入浅出HTTPS从原理到实战