@Autowired
RedissonClient redissonClient;
@Autowired
StringRedisTemplate redisTemplate;
//闭锁
@GetMapping("/lockDoor")
@ResponseBody
public String lockDoor() throws InterruptedException {
RCountDownLatch door = redissonClient.getCountDownLatch("door");
door.trySetCount(5);//计数为5,每有一个闭锁完成,计数减1
door.await();//等待闭锁都完成
return "放假了...";
}
@GetMapping("/gogogo/{id}")
@ResponseBody
public String gogogo(@PathVariable("id") Long id){
RCountDownLatch door = redissonClient.getCountDownLatch("door");
door.countDown();//计数减去一
return id + "班的人走完了";
}
标签:redissonClient,Redisson,闭锁,---,计数,74,door,id
From: https://www.cnblogs.com/morehair/p/17084066.html