/** * Returns <code>true</code> as soon as the lock is acquired. * If the lock is currently held by another thread in this or any * other process in the distributed system this method keeps trying * to acquire the lock for up to <code>waitTime</code> before * giving up and returning <code>false</code>. If the lock is acquired, * it is held until <code>unlock</code> is invoked, or until <code>leaseTime</code> * have passed since the lock was granted - whichever comes first. * * @param waitTime the maximum time to aquire the lock * @param leaseTime lease time * @param unit time unit * @return <code>true</code> if lock has been successfully acquired * @throws InterruptedException - if the thread is interrupted before or during this method. */
时间: 2024-02-17 10:24:54 浏览: 136
AlarmAlertWakeLock.rar_Hold_wakelock
这段代码看起来是一个方法的注释,它描述了一个分布式系统中的锁的获取方法。该方法会在尝试一定时间后,如果没有获取到锁,就返回 false;如果获取到了锁,锁会一直保持到 unlock 方法被调用,或者到指定的时间 leaseTime 到期。在这个过程中,如果线程被中断,该方法会抛出 InterruptedException 异常。
阅读全文