如何删除Redis锁以克服线程问题

时间:2019-05-01 17:41:01

标签: redis locking

com.veracode.was.utils.caching.redis.RedisLock中用于解锁的代码如下:

private void unlock(boolean silent) {
    if (rlock.isLocked()) {
        if (!rlock.isHeldByCurrentThread()) {
            if (!silent) {
                throw new RuntimeException("Not allowed to unlock from thread that does not own the lock");
            } else {
                LOG.info("Not allowed to unlock from thread that does not own the lock");
            }
        } else {
            rlock.unlock();
        }
    } else {
        LOG.info("Already unlocked. Unnecessary call to unlock()");
    }
}

我们的某些锁无法通过条件:

if (!rlock.isHeldByCurrentThread())

因此,他们永远保持锁定状态。 有什么办法可以删除这些锁?

0 个答案:

没有答案