public void lockInterruptibly() throws InterruptedException { if (Thread.interrupted()) throw new InterruptedException(); Thread caller = Thread.currentThread(); synchronized (this) { if (owner_ == null) { owner_ = caller; holds_ = 1; return; } else if (caller == owner_) { incHolds(); return; } else { try { do { wait(); } while (owner_ != null); owner_ = caller; holds_ = 1; return; } catch (InterruptedException ex) { if (owner_ == null) notify(); throw ex; } } } }
public void lockInterruptibly() throws InterruptedException { if (Thread.interrupted()) throw new InterruptedException(); Thread caller = Thread.currentThread(); synchronized (this) { if (owner_ == null) { owner_ = caller; holds_ = 1; return; } else if (caller == owner_) { incHolds(); return; } else { try { do { wait(); } while (owner_ != null); owner_ = caller; holds_ = 1; return; } catch (InterruptedException ex) { if (owner_ == null) notify(); throw ex; } } } }
public void lockInterruptibly() throws InterruptedException { if (Thread.interrupted()) throw new InterruptedException(); Thread caller = Thread.currentThread(); synchronized (this) { if (owner_ == null) { owner_ = caller; holds_ = 1; return; } else if (caller == owner_) { incHolds(); return; } else { try { do { wait(); } while (owner_ != null); owner_ = caller; holds_ = 1; return; } catch (InterruptedException ex) { if (owner_ == null) notify(); throw ex; } } } }
/** * Creates an instance of {@code ReentrantLock} with the * given fairness policy. * * @param fair {@code true} if this lock should use a fair ordering policy */ public ReentrantLock(boolean fair) { sync = (fair)? (Sync)new FairSync() : new NonfairSync(); }
/** * Creates an instance of {@code ReentrantLock}. * This is equivalent to using {@code ReentrantLock(false)}. */ public ReentrantLock() { sync = new NonfairSync(); }
/** * Creates an instance of {@code ReentrantLock} with the * given fairness policy. * * @param fair {@code true} if this lock should use a fair ordering policy */ public ReentrantLock(boolean fair) { sync = (fair)? (Sync)new FairSync() : new NonfairSync(); }
/** * Creates an instance of {@code ReentrantLock}. * This is equivalent to using {@code ReentrantLock(false)}. */ public ReentrantLock() { sync = new NonfairSync(); }
/** * Creates an instance of {@code ReentrantLock}. * This is equivalent to using {@code ReentrantLock(false)}. */ public ReentrantLock() { sync = new NonfairSync(); }
/** * Creates an instance of {@code ReentrantLock} with the * given fairness policy. * * @param fair {@code true} if this lock should use a fair ordering policy */ public ReentrantLock(boolean fair) { sync = (fair)? (Sync)new FairSync() : new NonfairSync(); }