当前位置:网站首页>Semaphore flow control semaphore
Semaphore flow control semaphore
2022-06-12 09:10:00 【Java supernatural Road】
Semaphore Used as a flow control semaphore in rocketmq There are good examples in
Semaphore It can be used to control the number of threads accessing shared resources at the same time
SemaphoreReleaseOnlyOnce#release
adopt cas Promise to release only once
public void release() {
if (this.semaphore != null) {
if (this.released.compareAndSet(false, true)) {
this.semaphore.release();
}
}
}
Use tryAcquire Get permission to ,tryAcquire You can add timeout
boolean acquired = this.semaphoreAsync.tryAcquire(timeoutMillis, TimeUnit.MILLISECONDS);
if (acquired) {
final SemaphoreReleaseOnlyOnce once = new SemaphoreReleaseOnlyOnce(this.semaphoreAsync);
long costTime = System.currentTimeMillis() - beginStartTime;
if (timeoutMillis < costTime) {
once.release();
throw new RemotingTimeoutException("invokeAsyncImpl call timeout");
}
边栏推荐
- Flink CheckPoint : Exceeded checkpoint tolerable failure threshold
- Introduction to applet cloud development -- questionnaire evaluation applet practice (7)
- ABC253F Operations on a Matrix
- 2022 safety officer-c certificate special operation certificate examination question bank and simulation examination
- Flink CheckPoint : Exceeded checkpoint tolerable failure threshold
- Notes on data mining in Tsinghua University (1)
- Meeting time (topology sorting +dp)
- Full alphabetic arrangement (pure alphabetic password dictionary)
- Does database and table splitting cause reading diffusion problems? How to solve it?
- xshell启动遇到“由于找不到mfc110.dll,无法继续执行代码的解决方法”
猜你喜欢

Multi table operation instance

Notes on data mining in Tsinghua University (1)
![[character set 8] char8_ t、char16_ t、char32_ t、wchar、char](/img/ef/e57fb345b36c84d3585fca0568b0ee.png)
[character set 8] char8_ t、char16_ t、char32_ t、wchar、char

Flink CheckPoint : Exceeded checkpoint tolerable failure threshold
软件测试需求分析方法有哪些,一起来看看吧
测试用例和bug描述规范参考

Detailed explanation of iSCSI (V) -- actual operation of iSCSI client configuration

Es6-- common basic knowledge

Can you migrate backwards before the first migration in the south- Can you migrate backwards to before the first migration in South?
![(node:22344) [DEP0123] DeprecationWarning: Setting the TLS ServerName to an IP address is not permit](/img/c1/d56ec09663857afa52f20848aeadac.png)
(node:22344) [DEP0123] DeprecationWarning: Setting the TLS ServerName to an IP address is not permit
随机推荐
Black screen solution for computer boot
Bash tutorial
Résoudre le problème de demander à l'élément d'être ouvert lorsque l'unit é est ouverte et que vous n'avez pas été ouvert auparavant (peut - être fermé anormalement auparavant)
RuntimeError:Input and parameter tensors are not at the same device, found input tensor at cuda:0 an
Chapter 8 - two basic problems of data processing
MySQL - Import / export operation
Basic exercise letter graphics
利用nvm动态调整nodejs版本,解决因为node版本过高或过低导致项目无法运行和打包
Binlog in mysql:
测试用例如何编写?
软件测试基础知识分享,写点你不知道的
Technology cloud report: how will the industrial Internet rebuild the security boundary in 2022?
ABC253F Operations on a Matrix
【无标题】Task3 多路召回
128. Plus longue séquence continue - table de hachage
Exists usage in SQL
2022 low voltage electrician retraining question bank and online simulation examination
Top command meaning
[character set 6] wide string and multi byte character conversion
Practical SQL statements and execution plan view