code: public void inBatch(@NonNull Runnable runnable) throws CouchbaseLiteException {
          if (runnable == null) { throw new IllegalArgumentException("runnable cannot be null."); }
  
          synchronized (lock) {
              mustBeOpen();
              try {
                  boolean commit = false;
                  getC4Database().beginTransaction();
                  try {
                      try {
                          runnable.run();
                          commit = true;
                      }
                      catch (RuntimeException e) {
                          throw new CouchbaseLiteException(e);
                      }
                  }
                  finally {
                      getC4Database().endTransaction(commit);
                  }
              }
              catch (LiteCoreException e) {
                  throw CBLStatus.convertException(e);
              }
          }
  
          postDatabaseChanged();
      }
docs: Runs a group of database operations in a batch. Use this when performing bulk write operations
  like multiple inserts/updates; it saves the overhead of multiple database commits, greatly
  improving performance.
  
  @param runnable the action which is implementation of Runnable interface
  @throws CouchbaseLiteException Throws an exception if any error occurs during the operation.