void (@NotNull ProgressIndicatorEx delegate) { synchronized (getLock()) { delegate.initStateFrom(this); ProgressIndicatorEx[] stateDelegates = myStateDelegates; if (stateDelegates == null) { myStateDelegates = new ProgressIndicatorEx[]{delegate}; } else { // hard throw is essential for avoiding deadlocks if (ArrayUtil.contains(delegate, stateDelegates)) { throw new IllegalArgumentException("Already registered: " + delegate); } myStateDelegates = ArrayUtil.append(stateDelegates, delegate, ProgressIndicatorEx.class); } } onProgressChange(); }