File tree Expand file tree Collapse file tree
google-auth-library-java/oauth2_http/java/com/google/auth/oauth2 Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -86,14 +86,24 @@ final class RegionalAccessBoundaryManager {
8686 // on concurrent refresh tasks, while threadCount provides unique names
8787 // for easier debugging.
8888 private static final AtomicInteger threadCount = new AtomicInteger (0 );
89- private static final ExecutorService EXECUTOR =
90- Executors .newFixedThreadPool (
91- 5 ,
92- r -> {
93- Thread t = new Thread (r , "RAB-refresh-" + threadCount .getAndIncrement ());
94- t .setDaemon (true );
95- return t ;
96- });
89+ private static final ExecutorService EXECUTOR ;
90+
91+ static {
92+ java .util .concurrent .ThreadPoolExecutor executor =
93+ new java .util .concurrent .ThreadPoolExecutor (
94+ 5 , // corePoolSize: threads to keep alive
95+ 5 , // maximumPoolSize: max threads allowed
96+ 1 , // keepAliveTime: time to wait before terminating idle threads
97+ java .util .concurrent .TimeUnit .HOURS , // unit for keepAliveTime
98+ new java .util .concurrent .LinkedBlockingQueue <>(), // work queue
99+ r -> {
100+ Thread t = new Thread (r , "RAB-refresh-" + threadCount .getAndIncrement ());
101+ t .setDaemon (true );
102+ return t ;
103+ });
104+ executor .allowCoreThreadTimeOut (true );
105+ EXECUTOR = executor ;
106+ }
97107
98108 private final transient Clock clock ;
99109 private final int maxRetryElapsedTimeMillis ;
You can’t perform that action at this time.
0 commit comments