public synchronized void setRun(int state) throws InvalidArgumentException {
        if (state == NEW || state == RUNNING || state == CONFIRMED || state == ERROR || state == CLOSED) {
            this.state = state;
        } else {
            throw new InvalidArgumentException("State must equal NEW, RUNNING, CONFIRMED, ERROR or CLOSED. State equals " + state);
        }
    }