public void releaseExclusiveLock(final int value) {
    final int index = index(value);
    if (useSpinLock) {
      OReadersWriterSpinLock spinLock = spinLocks[index];
      spinLock.releaseWriteLock();
      return;
    }

    final ReadWriteLock rwLock = locks[index];
    rwLock.writeLock().unlock();
  }
 public void unlockAllExclusive() {
   if (useSpinLock) {
     for (OReadersWriterSpinLock spinLock : spinLocks) {
       spinLock.releaseWriteLock();
     }
   } else {
     for (ReadWriteLock readWriteLock : locks) {
       readWriteLock.writeLock().unlock();
     }
   }
 }
 public void lockAllExclusive() {
   if (useSpinLock) {
     for (OReadersWriterSpinLock spinLock : spinLocks) {
       spinLock.acquireWriteLock();
     }
   } else {
     for (ReadWriteLock readWriteLock : locks) {
       readWriteLock.writeLock().lock();
     }
   }
 }
  public void releaseExclusiveLock(final long value) {
    final int hashCode = longHashCode(value);
    final int index = index(hashCode);

    if (useSpinLock) {
      OReadersWriterSpinLock spinLock = spinLocks[index];
      spinLock.releaseWriteLock();
      return;
    }

    final ReadWriteLock rwLock = locks[index];

    final Lock lock = rwLock.writeLock();
    lock.unlock();
  }
  public void releaseExclusiveLock(final T value) {
    final int index;
    if (value == null) index = 0;
    else index = index(value.hashCode());

    if (useSpinLock) {
      OReadersWriterSpinLock spinLock = spinLocks[index];
      spinLock.releaseWriteLock();
      return;
    }

    final ReadWriteLock rwLock = locks[index];

    final Lock lock = rwLock.writeLock();
    lock.unlock();
  }
  public Lock acquireSharedLock(int value) {
    final int index = index(value);

    if (useSpinLock) {
      OReadersWriterSpinLock spinLock = spinLocks[index];
      spinLock.acquireReadLock();

      return new SpinLockWrapper(true, spinLock);
    }

    final ReadWriteLock rwLock = locks[index];

    final Lock lock = rwLock.readLock();
    lock.lock();
    return lock;
  }
  public Lock acquireExclusiveLock(int value) {
    final int index = index(value);

    if (useSpinLock) {
      OReadersWriterSpinLock spinLock = spinLocks[index];
      spinLock.acquireWriteLock();

      return new SpinLockWrapper(false, spinLock);
    }

    final ReadWriteLock rwLock = locks[index];

    final Lock lock = rwLock.writeLock();
    lock.lock();
    return lock;
  }
  @Override
  public Lock acquireSharedLock(final T value) {
    final int index;
    if (value == null) index = 0;
    else index = index(value.hashCode());

    if (useSpinLock) {
      OReadersWriterSpinLock spinLock = spinLocks[index];
      spinLock.acquireReadLock();

      return new SpinLockWrapper(true, spinLock);
    }

    final ReadWriteLock rwLock = locks[index];

    final Lock lock = rwLock.readLock();
    lock.lock();
    return lock;
  }
 @Override
 public void unlock() {
   if (readLock) spinLock.releaseReadLock();
   else spinLock.releaseWriteLock();
 }