code: public boolean compareAndSet(int i, int expect, int update) {
          while (true) {
              try {
                  updateLock.lock();
                  try {
                      return store.get().compareAndSet(i, expect, update);
                  } finally {
                      updateLock.unlock();
                  }
              } catch (PaletteFullException pfe) {
                  resizeLock.lock();
                  try {
                      if (store.get().isPaletteMaxSize()) {
                          store.set(new AtomicShortIntDirectBackingArray(store.get()));
                      } else {
                          store.set(new AtomicShortIntPaletteBackingArray(store.get(), true));
                      }
                  } finally {
                      resizeLock.unlock();
                  }
              }
          }
      }
docs: Sets the element at the given index, but only if the previous value was the expected value.
  
  @param i the index
  @param expect the expected value
  @param update the new value
  @return true on success