public Mono<Void> close(Duration timeout) {
        if (!thread.isAlive()) {
            return Mono.empty();
        }
        return Mono.defer(() -> {
            active = false;
            // If idle, wake it up to take the last chance to write logs.
            LockSupport.unpark(thread);
            return thread.onTerminated()
                    .timeout(timeout)
                    .onErrorResume(TimeoutException.class, e -> thread.terminate());
        })
                .onErrorMap(t -> new RuntimeException(
                        "Caught an error while closing the log processor",
                        t));
    }
Note that we only use one thread to process logs, which means that we don't need to consider the
scenarios of concurrent modifications

@author James Chen
turms-server-common/src/main/java/im/turms/server/common/infra/logging/core/processor/LogProcessor.java