Use Executor in stable builder APIs instead of ExecutorService
diff --git a/android/src/main/java/io/grpc/android/AndroidChannelBuilder.java b/android/src/main/java/io/grpc/android/AndroidChannelBuilder.java
index 0b54916..5baa6c2 100644
--- a/android/src/main/java/io/grpc/android/AndroidChannelBuilder.java
+++ b/android/src/main/java/io/grpc/android/AndroidChannelBuilder.java
@@ -39,7 +39,7 @@
 import io.grpc.okhttp.OkHttpChannelBuilder;
 
 import java.util.List;
-import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executor;
 
 /**
  * A {@link io.grpc.ManagedChannelBuilder} that provides a stable interface for producing
@@ -77,7 +77,7 @@
   }
 
   @Override
-  public AndroidChannelBuilder executor(ExecutorService executor) {
+  public AndroidChannelBuilder executor(Executor executor) {
     baseBuilder.executor(executor);
     return this;
   }
diff --git a/core/src/main/java/io/grpc/ManagedChannelBuilder.java b/core/src/main/java/io/grpc/ManagedChannelBuilder.java
index 3fd56c1..dda4f8f 100644
--- a/core/src/main/java/io/grpc/ManagedChannelBuilder.java
+++ b/core/src/main/java/io/grpc/ManagedChannelBuilder.java
@@ -32,7 +32,7 @@
 package io.grpc;
 
 import java.util.List;
-import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executor;
 
 /**
  * A builder for {@link ManagedChannel} instances.
@@ -50,7 +50,7 @@
    * <p>The channel won't take ownership of the given executor. It's caller's responsibility to
    * shut down the executor when it's desired.
    */
-  public abstract T executor(ExecutorService executor);
+  public abstract T executor(Executor executor);
 
   /**
    * Adds interceptors that will be called before the channel performs its real work. This is
diff --git a/core/src/main/java/io/grpc/ServerBuilder.java b/core/src/main/java/io/grpc/ServerBuilder.java
index a8e2902..60a6d61 100644
--- a/core/src/main/java/io/grpc/ServerBuilder.java
+++ b/core/src/main/java/io/grpc/ServerBuilder.java
@@ -31,7 +31,7 @@
 
 package io.grpc;
 
-import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executor;
 
 import javax.annotation.Nullable;
 
@@ -50,7 +50,7 @@
    * <p>The server won't take ownership of the given executor. It's caller's responsibility to
    * shut down the executor when it's desired.
    */
-  public abstract T executor(@Nullable ExecutorService executor);
+  public abstract T executor(@Nullable Executor executor);
 
   /**
    * Adds a service implementation to the handler registry.
diff --git a/core/src/main/java/io/grpc/internal/AbstractManagedChannelImplBuilder.java b/core/src/main/java/io/grpc/internal/AbstractManagedChannelImplBuilder.java
index dd81e13..5097c9f 100644
--- a/core/src/main/java/io/grpc/internal/AbstractManagedChannelImplBuilder.java
+++ b/core/src/main/java/io/grpc/internal/AbstractManagedChannelImplBuilder.java
@@ -38,7 +38,7 @@
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
-import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executor;
 
 import javax.annotation.Nullable;
 
@@ -51,14 +51,14 @@
         <T extends AbstractManagedChannelImplBuilder<T>> extends ManagedChannelBuilder<T> {
 
   @Nullable
-  private ExecutorService executor;
+  private Executor executor;
   private final List<ClientInterceptor> interceptors = new ArrayList<ClientInterceptor>();
 
   @Nullable
   private String userAgent;
 
   @Override
-  public final T executor(ExecutorService executor) {
+  public final T executor(Executor executor) {
     this.executor = executor;
     return thisT();
   }
diff --git a/core/src/main/java/io/grpc/internal/AbstractServerImplBuilder.java b/core/src/main/java/io/grpc/internal/AbstractServerImplBuilder.java
index d224912..7fb2a7f 100644
--- a/core/src/main/java/io/grpc/internal/AbstractServerImplBuilder.java
+++ b/core/src/main/java/io/grpc/internal/AbstractServerImplBuilder.java
@@ -40,7 +40,7 @@
 import io.grpc.ServerBuilder;
 import io.grpc.ServerServiceDefinition;
 
-import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executor;
 
 import javax.annotation.Nullable;
 
@@ -54,7 +54,7 @@
 
   private final HandlerRegistry registry;
   @Nullable
-  private ExecutorService executor;
+  private Executor executor;
 
   /**
    * Constructs using a given handler registry.
@@ -71,7 +71,7 @@
   }
 
   @Override
-  public final T executor(@Nullable ExecutorService executor) {
+  public final T executor(@Nullable Executor executor) {
     this.executor = executor;
     return thisT();
   }
diff --git a/core/src/main/java/io/grpc/internal/ManagedChannelImpl.java b/core/src/main/java/io/grpc/internal/ManagedChannelImpl.java
index d2f5669..9bbc9db 100644
--- a/core/src/main/java/io/grpc/internal/ManagedChannelImpl.java
+++ b/core/src/main/java/io/grpc/internal/ManagedChannelImpl.java
@@ -67,7 +67,7 @@
   private static final Logger log = Logger.getLogger(ManagedChannelImpl.class.getName());
 
   private final ClientTransportFactory transportFactory;
-  private final ExecutorService executor;
+  private final Executor executor;
   private final boolean usingSharedExecutor;
   private final String userAgent;
   private final Object lock = new Object();
@@ -114,7 +114,7 @@
     }
   };
 
-  ManagedChannelImpl(ClientTransportFactory transportFactory, @Nullable ExecutorService executor,
+  ManagedChannelImpl(ClientTransportFactory transportFactory, @Nullable Executor executor,
       @Nullable String userAgent, List<ClientInterceptor> interceptors) {
     this.transportFactory = transportFactory;
     this.userAgent = userAgent;
@@ -387,7 +387,7 @@
    */
   private void onChannelTerminated() {
     if (usingSharedExecutor) {
-      SharedResourceHolder.release(GrpcUtil.SHARED_CHANNEL_EXECUTOR, executor);
+      SharedResourceHolder.release(GrpcUtil.SHARED_CHANNEL_EXECUTOR, (ExecutorService) executor);
     }
     // Release the transport factory so that it can deallocate any resources.
     transportFactory.release();
diff --git a/okhttp/src/main/java/io/grpc/okhttp/OkHttpChannelBuilder.java b/okhttp/src/main/java/io/grpc/okhttp/OkHttpChannelBuilder.java
index 712881d..70097a4 100644
--- a/okhttp/src/main/java/io/grpc/okhttp/OkHttpChannelBuilder.java
+++ b/okhttp/src/main/java/io/grpc/okhttp/OkHttpChannelBuilder.java
@@ -49,6 +49,7 @@
 import io.grpc.internal.SharedResourceHolder;
 import io.grpc.internal.SharedResourceHolder.Resource;
 
+import java.util.concurrent.Executor;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 
@@ -96,7 +97,7 @@
     return new OkHttpChannelBuilder(host, port);
   }
 
-  private ExecutorService transportExecutor;
+  private Executor transportExecutor;
   private final String host;
   private final int port;
   private String authorityHost;
@@ -117,7 +118,7 @@
    * <p>The channel does not take ownership of the given executor. It is the caller' responsibility
    * to shutdown the executor when appropriate.
    */
-  public OkHttpChannelBuilder transportExecutor(@Nullable ExecutorService transportExecutor) {
+  public OkHttpChannelBuilder transportExecutor(@Nullable Executor transportExecutor) {
     this.transportExecutor = transportExecutor;
     return this;
   }
@@ -200,7 +201,7 @@
     private final String host;
     private final int port;
     private final String authorityHost;
-    private final ExecutorService executor;
+    private final Executor executor;
     private final boolean usingSharedExecutor;
     private final SSLSocketFactory socketFactory;
     private final ConnectionSpec connectionSpec;
@@ -210,7 +211,7 @@
     private OkHttpTransportFactory(String host,
                                    int port,
                                    String authorityHost,
-                                   ExecutorService executor,
+                                   Executor executor,
                                    SSLSocketFactory socketFactory,
                                    ConnectionSpec connectionSpec,
                                    int maxMessageSize) {
@@ -245,7 +246,7 @@
     @Override
     protected void deallocate() {
       if (usingSharedExecutor) {
-        SharedResourceHolder.release(SHARED_EXECUTOR, executor);
+        SharedResourceHolder.release(SHARED_EXECUTOR, (ExecutorService) executor);
       }
     }
   }