当前位置:网站首页>Imitation thread deduction
Imitation thread deduction
2022-07-27 18:55:00 【Get lazy】
@SpringBootTest
public class DanTest {
@Resource(name = "redisTemplate")
private ValueOperations valueOperations;
private final String key123 = "class#208";
@Test
public void DanTest() {
// Set up inventory
valueOperations.set(key123, 5l);
ExecutorService executorService = Executors.newCachedThreadPool();
// Simulate concurrent operations
for (int i = 0; i < 10; i++) {
Long decrement = valueOperations.decrement(key123, 1);
executorService.execute(() -> {
if (decrement >= 0) {
System.out.println(StrUtil.format(" Deduction successful , Threads {}, Surplus quantity {}", Thread.currentThread().getName(), decrement));
} else {
System.out.println(StrUtil.format(" Deduction failed , Threads {}, Surplus quantity {}", Thread.currentThread().getName(), decrement));
}
});
}
ThreadUtil.safeSleep(1000 * 10);
}
}边栏推荐
- Uploading and downloading of files
- Build a simple knowledge question and answer system
- LED带风扇护眼学习台灯触摸芯片-DLT8S12A
- Matplotlib(基本用法)
- Nacos display service registration address error
- 连接查询和子查询
- Aircraft battle with enemy aircraft
- 订单超时取消 及 按类别查询商品
- Uni app form submit button send request
- Vue uses keep alive to realize page caching
猜你喜欢
随机推荐
Overview of Baidu map technology, and application development of basic API and webapi
飞机大战敌机出场
Collection of software design suggestions of "high cohesion and low coupling"
Use mobaxtermto establish a two-tier springboard connection
Functions in JS and the use of DOM to obtain elements and event attributes
Wechat applet obtains openid, sessionkey, unionid
Netred RGB mirror light touch chip-dlt8s15b-jericho
TypeScript安装
电动加热护颈枕芯片-DLTAP703SC
Electric heating neck pillow chip-dltap703sc
C file and folder input / output stream code
Ant privacy computing innovation tee technology has won academic recognition
USB充电式暖手宝芯片-DLTAP602SC-杰力科创
Interceptor拦截器
The song of the virtual idol was originally generated in this way!
USB rechargeable hand warmer chip dltap602sc Jericho
TS study notes class
Log4j epic loopholes, big companies like jd.com have been recruited
pygame飞机大战游戏背景实现
RuntimeError: output with shape [1, 256, 256] doesn‘t match the broadcast shape [3, 256, 256]【报错】








