class Subscriber implements Observer<T>, Subscription {

    protected final void request(long n) {
        if (n < 0) {
            throw new IllegalArgumentException("number requested cannot be negative: " + n);
        } 
        Producer shouldRequest = null;
        synchronized (this) {
            if (p != null) {
                shouldRequest = p;
            } else if (requested == Long.MIN_VALUE) {
                requested = n;
            } else { 
                final long total = requested + n;
                // check if overflow occurred
                if (total < 0) {
                    requested = Long.MAX_VALUE;
                } else {
                    requested = total;
                }
            }
        }
        // after releasing lock
        if (shouldRequest != null) {
            shouldRequest.request(n);
        }
    }

    protected  Subscriber();
    protected  Subscriber(Subscriber<?> op);
    protected  Subscriber(Subscriber<?> op, boolean shareSubscriptions);

}