public void setError(final int errorCode) {
        if (this.destroyed) {
            LOG.warn("ThreadId: {} already destroyed, ignore error code: {}", this.data, errorCode);
            return;
        }
        this.lock.lock();
        try {
            if (this.destroyed) {
                LOG.warn("ThreadId: {} already destroyed, ignore error code: {}", this.data, errorCode);
                return;
            }
            if (this.onError != null) {
                this.onError.onError(this, this.data, errorCode);
            }
        } finally {
            // It may have been released during onError to avoid throwing an exception.
            if (this.lock.isHeldByCurrentThread()) {
                this.lock.unlock();
            }
        }
    }
Set error code, run the onError callback
with code immediately in lock.
@param errorCode error code
jraft-core/src/main/java/com/alipay/sofa/jraft/util/ThreadId.java