当前位置:网站首页>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);
}
}边栏推荐
猜你喜欢

USB rechargeable hand warmer chip dltap602sc Jericho

Generate PDM file from Navicat export table
![[NPM] the](/img/ae/efccefae0323a1f6a425523e01d2ac.png)
[NPM] the "NPM" item cannot be recognized as the name of cmdlets, functions, script files or runnable programs. Please check the spelling of the name. If the path is included, make sure the path is co

建木持续集成平台v2.5.2发布

What does the number of network request interface layers (2/3 layers) mean

JDBC MySQL 01 JDBC operation MySQL (add, delete, modify and query)

Electric heating neck pillow chip-dltap703sc

商品名称模糊搜索:

Examples of map search

"MySQL things" explains the indexing principle in detail
随机推荐
TS learning notes interface
Full automatic breast pump chip dltap703sd
商品评论信息与评论信息分类
Must the MySQL query column be consistent with the group by field?
Filebeat.yml configuration file about the configuration of multiple services
How to send external mail to the company mailbox server on the Intranet
Zhaoqi scientific and technological innovation introduces high-level talents at home and abroad and connects innovation and entrepreneurship projects
Uni app label jump
What if MySQL database forgets its password???
Use mobaxtermto establish a two-tier springboard connection
Wechat applet obtains mobile number
Wechat applet wechat payment overview
家用静音驱蚊灯芯片-DLTAP703SD-杰力科创
Modify placeholder style in input
TS study notes class
百度地图技术概述,及基本API与WebApi的应用开发
10 SQL optimization schemes summarized by Alibaba P8 (very practical)
Here are all the MySQL interview questions you can't expect (the latest version of 2022)
was not registered for synchronization because synchronization is not active[已解决]
js实现简易表单验证与全选功能