'Thread of supplyAsync in java completable future uses different threads in different environments

In my webapp supplyAsync method uses forkjoin pool in cloud linux environments but in local linux machines same code uses threads like thread-1 thread-2 with class web app class loader. Is there any configuration to change the default threadpool for completable futures.I want to get the local behaviour in cloud. Thread with a web app class loader. java version java 11, tomcat version 8.5.24.

CompletableFuture<Void> asyncFuture = future.thenAcceptAsync(t -> {
        if (!complete.getAndSet(true)) {
            try {
                completeAction.accept(t);
            } finally {
                synchronized (executor) {
                    K.shutdown();
                }
            }
        }
    });
    synchronized (executor) {
        if (!executor.isShutdown()) {
            executor.schedule(() -> {
                if (!complete.getAndSet(true)) {
                    try {
                        asyncFuture.cancel(false);
                        timeoutAction.run();
                    } finally {
                        executor.shutdown();
                    }
                }
            }, 200, 50);
        }
    }

enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source