code: public long getAndSet(T obj, long newValue) {
          long prev;
          do {
              prev = get(obj);
          } while (!compareAndSet(obj, prev, newValue));
          return prev;
      }
docs: Atomically sets the field of the given object managed by this updater
  to the given value and returns the old value.
  
  @param obj An object whose field to get and set
  @param newValue the new value
  @return the previous value