当前位置:网站首页>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");
}
边栏推荐
- (14) Inputfield logic analysis
- RuntimeError:Input and parameter tensors are not at the same device, found input tensor at cuda:0 an
- The database doesn't know what went wrong
- Codecraft-22 and codeforces round 795 (Div. 2)
- Source code and scheme for target recognition, detection and 6D attitude estimation (the most advanced method and data set)
- Analysis of 43 cases of MATLAB neural network: Chapter 8 prediction of GRNN Network - Freight Volume Prediction Based on generalized regression neural network
- Diff prime pairs
- ABC253F Operations on a Matrix
- (node:22344) [DEP0123] DeprecationWarning: Setting the TLS ServerName to an IP address is not permit
- (JS) three digits are separated by commas, and two decimal places are reserved (or rounded)
猜你喜欢

清华大学数据挖掘笔记(一)

List < string > sort
![[computer use] how to change a computer disk into a mobile disk?](/img/ff/843f4220fcaefc00980a6edc29aebf.jpg)
[computer use] how to change a computer disk into a mobile disk?

Popular understanding of time domain sampling and frequency domain continuation
软件测试报告中常见的疏漏,给自己提个醒

Binlog in mysql:

Es6-- common basic knowledge

Chapter 8 - two basic problems of data processing

MySQL learning record - II. MySQL create table command
自动化测试框架的设计原则有哪些?我帮你总结好了快来看
随机推荐
RuntimeError:Input and parameter tensors are not at the same device, found input tensor at cuda:0 an
(十五) TweenRunner
(js)三位用逗号隔开,保留两位小数(or 四舍五入取整)
2022 safety officer-c certificate special operation certificate examination question bank and simulation examination
(14) Inputfield logic analysis
MFS详解(四)——MFS管理服务器安装与配置
Source code and scheme for target recognition, detection and 6D attitude estimation (the most advanced method and data set)
【字符集六】宽字符串和多字节字符互转
node示例后台搭建
Unittest test framework
Counting haybales (difference + discretization)
Leetcode 336 palindrome pair (palindrome string + hash)
xshell启动遇到“由于找不到mfc110.dll,无法继续执行代码的解决方法”
Definition of polar angle and its code implementation
Minimum transfer times
最少换乘次数
目标识别、检测和 6D 姿态估算源码与方案(最先进的方法和数据集)
Subtractive integer (number theory)
【字符集七】汉字的宽字符码和多字节码分别是多少
List < string > sort