@Override
  public java.util.concurrent.Future<UpdateThingShadowResult> updateThingShadowAsync(
      final UpdateThingShadowRequest request,
      final com.amazonaws.handlers.AsyncHandler<UpdateThingShadowRequest, UpdateThingShadowResult>
          asyncHandler) {

    return executorService.submit(
        new java.util.concurrent.Callable<UpdateThingShadowResult>() {
          @Override
          public UpdateThingShadowResult call() throws Exception {
            UpdateThingShadowResult result;

            try {
              result = updateThingShadow(request);
            } catch (Exception ex) {
              if (asyncHandler != null) {
                asyncHandler.onError(ex);
              }
              throw ex;
            }

            if (asyncHandler != null) {
              asyncHandler.onSuccess(request, result);
            }
            return result;
          }
        });
  }
  @Override
  public java.util.concurrent.Future<Void> publishAsync(
      final PublishRequest request,
      final com.amazonaws.handlers.AsyncHandler<PublishRequest, Void> asyncHandler) {

    return executorService.submit(
        new java.util.concurrent.Callable<Void>() {
          @Override
          public Void call() throws Exception {
            Void result;

            try {
              publish(request);
              result = null;
            } catch (Exception ex) {
              if (asyncHandler != null) {
                asyncHandler.onError(ex);
              }
              throw ex;
            }

            if (asyncHandler != null) {
              asyncHandler.onSuccess(request, result);
            }
            return result;
          }
        });
  }
 /**
  * Shuts down the client, releasing all managed resources. This includes forcibly terminating all
  * pending asynchronous service calls. Clients who wish to give pending asynchronous service calls
  * time to complete should call {@code getExecutorService().shutdown()} followed by {@code
  * getExecutorService().awaitTermination()} prior to calling this method.
  */
 @Override
 public void shutdown() {
   super.shutdown();
   executorService.shutdownNow();
 }