摘要: 源码: public boolean tryAcquire(int permits, long timeout, TimeUnit unit) { long timeoutMicros = max(unit.toMicros(timeout), 0); checkPermits(permits); 阅读全文
posted @ 2020-09-22 15:57 弓呆的胖次 阅读(2525) 评论(0) 推荐(0) 编辑
摘要: /* * Copyright (C) 2012 The Guava Authors * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except * in co 阅读全文
posted @ 2020-09-22 15:55 弓呆的胖次 阅读(155) 评论(0) 推荐(0) 编辑
摘要: https://www.jianshu.com/p/8f548e469bbe https://blog.csdn.net/forezp/article/details/100060686?utm_medium=distribute.pc_relevant_t0.none-task-blog-Blog 阅读全文
posted @ 2020-09-22 14:17 弓呆的胖次 阅读(124) 评论(0) 推荐(0) 编辑
摘要: 有参方法tryAcquire(int permits,long timeout,TimeUnit unit)的作用是在指定的时间timeout内尝试地获得permits个许可,如果获取不到则返回false。 下面semaphore.tryAcquire(2,2, TimeUnit.SECONDS)表 阅读全文
posted @ 2020-09-22 11:27 弓呆的胖次 阅读(1163) 评论(0) 推荐(0) 编辑