Пример #1
0
 /** Execute the given command directly in the current thread, within the supplied lock. */
 public void execute(Runnable command) throws InterruptedException {
   mutex_.acquire();
   try {
     command.run();
   } finally {
     mutex_.release();
   }
 }
Пример #2
0
 /** Try to acquire sync before a reader operation; record failure * */
 protected boolean beforeRead() {
   try {
     rd_.acquire();
     return false;
   } catch (InterruptedException ex) {
     syncFailures_.increment();
     return true;
   }
 }
Пример #3
0
 public void clear() {
   try {
     wr_.acquire();
     try {
       c_.clear();
     } finally {
       wr_.release();
     }
   } catch (InterruptedException ex) {
     Thread.currentThread().interrupt();
     throw new UnsupportedOperationException();
   }
 }
Пример #4
0
 public Object remove(Object key) {
   try {
     wr_.acquire();
     try {
       return c_.remove(key);
     } finally {
       wr_.release();
     }
   } catch (InterruptedException ex) {
     Thread.currentThread().interrupt();
     throw new UnsupportedOperationException();
   }
 }
Пример #5
0
 public void lock() {
   sync.acquire(1);
 }
Пример #6
0
 @Override
 public void lock() {
   sync.acquire(1);
 }