code: public void setState(StreamState newState) {
          StreamState oldState = state.get();
          if (!oldState.equals(newState) && state.compareAndSet(oldState, newState)) {
              fireStateChange(oldState, newState);
          }
      }
docs: Sets the stream state.
  
  @param newState stream state