SubTaskProgressIndicator (int taskWeight) { if (taskWeight < 0) { throw new IllegalArgumentException("Task weight must not be negative: " + taskWeight); } if (myRemainingTotalWeight.addAndGet(-taskWeight) < 0) { throw new IllegalStateException("Attempted to create more task indicators than registered in constructor"); } return new SubTaskProgressIndicator(this, taskWeight); }