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 @Override
public EventLoopGroup create() { public EventLoopGroup create() {
// Use the executor based constructor so we can work with both Netty4 & Netty5. // 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 int parallelism = numEventLoops == 0
? Runtime.getRuntime().availableProcessors() * 2 : numEventLoops; ? Runtime.getRuntime().availableProcessors() * 2 : numEventLoops;
final ExecutorService executor = Executors.newFixedThreadPool(parallelism, threadFactory); final ExecutorService executor = Executors.newFixedThreadPool(parallelism, threadFactory);

View File

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