code: private void writeLogEntries(Iterable<LogEntry> logEntries, WriteOption... writeOptions) {
      switch (this.writeSynchronicity) {
        case SYNC:
          get(writeAsync(logEntries, writeOptions));
          break;
  
        case ASYNC:
        default:
          final ApiFuture<Void> writeFuture = writeAsync(logEntries, writeOptions);
          final Object pendingKey = new Object();
          pendingWrites.put(pendingKey, writeFuture);
          ApiFutures.addCallback(
              writeFuture,
              new ApiFutureCallback<Void>() {
                private void removeFromPending() {
                  pendingWrites.remove(pendingKey);
                }
  
                @Override
                public void onSuccess(Void v) {
                  removeFromPending();
                }
  
                @Override
                public void onFailure(Throwable t) {
                  try {
                    Exception ex = t instanceof Exception ? (Exception) t : new Exception(t);
                    throw new RuntimeException(ex);
                  } finally {
                    removeFromPending();
                  }
                }
              });
          break;
      }
    }
docs: /* Write logs synchronously or asynchronously based on writeSynchronicity setting.