Daemonize OkHttp and Netty

This commit is contained in:
Carl Mastrangelo 2015-09-03 14:35:04 -07:00
parent f641e081a0
commit 07a7279742
2 changed files with 5 additions and 1 deletions

View File

@ -170,7 +170,10 @@ class Utils {
@Override
public EventLoopGroup create() {
// Use the executor based constructor so we can work with both Netty4 & Netty5.
ThreadFactory threadFactory = new ThreadFactoryBuilder().setNameFormat(name + "-%d").build();
ThreadFactory threadFactory = new ThreadFactoryBuilder()
.setDaemon(true)
.setNameFormat(name + "-%d")
.build();
int parallelism = numEventLoops == 0
? Runtime.getRuntime().availableProcessors() * 2 : numEventLoops;
final ExecutorService executor = Executors.newFixedThreadPool(parallelism, threadFactory);

View File

@ -80,6 +80,7 @@ public final class OkHttpChannelBuilder extends
@Override
public ExecutorService create() {
return Executors.newCachedThreadPool(new ThreadFactoryBuilder()
.setDaemon(true)
.setNameFormat("grpc-okhttp-%d")
.build());
}