RLock lock = redissonClient.getLock(LOCK_KEY);
try {
    if (!lock.tryLock(Constants.TEN, TimeUnit.SECONDS)) {
        throw new BusinessException("访问频繁请稍后再试");
    }
    doSomething();
} catch (Exception e) {
    log.error("系统异常");
} finally {
    if (lock.isLocked() && lock.isHeldByCurrentThread()) {
        lock.unlock();
    }
}

相关文章:

  • 2021-09-14
  • 2021-10-01
  • 2021-11-03
  • 2021-05-21
  • 2022-01-01
  • 2021-09-06
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-09-09
  • 2021-10-01
  • 2021-11-01
  • 2021-07-10
  • 2021-08-15
  • 2021-12-04
相关资源
相似解决方案