Skip to content
This repository was archived by the owner on Sep 26, 2023. It is now read-only.
This repository was archived by the owner on Sep 26, 2023. It is now read-only.

Question: may I as why the default thread pool is a ScheduledThreadPoolExecutor? #1286

Description

@liufuyang

If I am correct, from the code here
https://github.com/googleapis/gax-java/blob/master/gax/src/main/java/com/google/api/gax/core/InstantiatingExecutorProvider.java#L63

Means the default threadpool for grpc connections will be a ScheduledThreadPoolExecutor
https://github.com/AdoptOpenJDK/openjdk-jdk11/blob/master/src/java.base/share/classes/java/util/concurrent/ScheduledThreadPoolExecutor.java#L470

public ScheduledThreadPoolExecutor(int corePoolSize,
                                       ThreadFactory threadFactory) {
        super(corePoolSize, Integer.MAX_VALUE,
              DEFAULT_KEEPALIVE_MILLIS, MILLISECONDS,
              new DelayedWorkQueue(), threadFactory);
    }

Which uses some DelayedWorkQueue internally. Will this gives the in general the best performance or is there some specific thoughts after using this type of thread pool?

How it compares with a ExecutorService.newFixedThreadPool that uses LinkedBlockingQueue or a fork-join pool?

public static ExecutorService newFixedThreadPool(int nThreads) {
        return new ThreadPoolExecutor(nThreads, nThreads,
                                      0L, TimeUnit.MILLISECONDS,
                                      new LinkedBlockingQueue<Runnable>());
    }

I saw some earlier discussion here grpc/grpc-java#7381 but I am not sure whether those statement are still valid now?

Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: questionRequest for information or clarification. Not an issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions