List<DataCopyPath> write(final ReplicationSpec forReplicationSpec, boolean isExportTask,
                                   FileList fileList, boolean dataCopyAtLoad)
          throws InterruptedException, HiveException {
    List<Future<?>> futures = new LinkedList<>();
    List<DataCopyPath> managedTableCopyPaths = new LinkedList<>();

    ThreadFactory namingThreadFactory =
        new ThreadFactoryBuilder().setNameFormat("partition-dump-thread-%d").build();
    ExecutorService consumer = Executors.newFixedThreadPool(nThreads, namingThreadFactory);

    for (Partition part : partitionIterable) {
      LOG.debug("scheduling partition dump {}", part.getName());
      Runnable r = () -> {
        String partitionName = part.getName();
        String threadName = Thread.currentThread().getName();
        LOG.debug("Thread: {}, start partition dump {}", threadName, partitionName);
        try {
          // Data Copy in case of ExportTask or when dataCopyAtLoad is true
          List<Path> dataPathList = Utils.getDataPathList(part.getDataLocation(),
              forReplicationSpec, hiveConf);
          Path rootDataDumpDir = isExportTask
              ? paths.partitionMetadataExportDir(partitionName) : paths.partitionDataExportDir(partitionName);
          new FileOperations(dataPathList, rootDataDumpDir, distCpDoAsUser, hiveConf, mmCtx)
              .export(isExportTask, dataCopyAtLoad);
          Path dataDumpDir = new Path(paths.dataExportRootDir(), partitionName);
          LOG.debug("Thread: {}, finish partition dump {}", threadName, partitionName);
          if (!(isExportTask || dataCopyAtLoad)) {
            fileList.add(new DataCopyPath(forReplicationSpec, part.getDataLocation(),
                dataDumpDir).convertToString());
          }
        } catch (Exception e) {
          throw new RuntimeException(e.getMessage(), e);
        }
      };
      futures.add(consumer.submit(r));
    }
    consumer.shutdown();
    for (Future<?> future : futures) {
      try {
        future.get();
      } catch (Exception e) {
        LOG.error("Partition dump thread failed", e.getCause());
        throw new HiveException(e.getCause().getMessage(), e.getCause());
      }
    }
    // may be drive this via configuration as well.
    consumer.awaitTermination(Long.MAX_VALUE, TimeUnit.SECONDS);
    return managedTableCopyPaths;
  }
This class manages writing multiple partitions _data files simultaneously.
It creates a worker thread pool. Each thread in pool is assigned the task
of dumping or writing each partition _data files in parallel manner.
ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/PartitionExport.java