protected Object fetch(Object key){
synchronized (lock) {
    Thread currentThread=Thread.currentThread();
    if (busyThread == currentThread) {
      throw new IllegalStateException("AbstractCache.fetch is not re-entrant");
    }
    while (busyThread != null) {
      try {
        lock.wait();
      }
 catch (      InterruptedException e) {
      }
    }
    busyThread=currentThread;
  }
  try {
    return fetchSerial(key);
  }
  finally {
synchronized (lock) {
      busyThread=null;
      lock.notify();
    }
  }
}

protected Object fetch ( Object key ) { synchronized ( lock ) { Thread currentThread = Thread . currentThread ( ) ; if ( busyThread == currentThread ) { throw new IllegalStateException ( "AbstractCache.fetch is not re-entrant" ) ; } while ( busyThread != null ) { try { lock . wait ( ) ; } catch ( InterruptedException e ) { } } busyThread = currentThread ; } try { return fetchSerial ( key ) ; } finally { synchronized ( lock ) { busyThread = null ; lock . notify ( ) ; } } }
subclasses override fetch ( ) to fetch values that are not in cache . the default implementation uses a semaphore to serialize access to the fetchserial method .
