取决于加锁的方式。
Lock 方法有2种形式,如果指定了leaseTime (且不为-1), 不会启用watchDog机制.
如果没有指定leaseTime, 则会启动watchDog机制,且会一直续期,除非线程宕调或者续期失败。
java
public void lock() {
try {
this.lock(-1L, (TimeUnit)null, false);
} catch (InterruptedException var2) {
throw new IllegalStateException();
}
}
public void lock(long leaseTime, TimeUnit unit) {
try {
this.lock(leaseTime, unit, false);
} catch (InterruptedException var5) {
throw new IllegalStateException();
}
}
参考文章: