code: private synchronized RecordWriter getRecordWriter(String namedOutput,
                                                      String baseFileName,
                                                      final Reporter reporter)
      throws IOException {
      RecordWriter writer = recordWriters.get(baseFileName);
      if (writer == null) {
        if (countersEnabled && reporter == null) {
          throw new IllegalArgumentException(
            "Counters are enabled, Reporter cannot be NULL");
        }
        JobConf jobConf = new JobConf(conf);
        jobConf.set(InternalFileOutputFormat.CONFIG_NAMED_OUTPUT, namedOutput);
        FileSystem fs = FileSystem.get(conf);
        writer =
          outputFormat.getRecordWriter(fs, jobConf, baseFileName, reporter);
  
        if (countersEnabled) {
          if (reporter == null) {
            throw new IllegalArgumentException(
              "Counters are enabled, Reporter cannot be NULL");
          }
          writer = new RecordWriterWithCounter(writer, baseFileName, reporter);
        }
  
        recordWriters.put(baseFileName, writer);
      }
      return writer;
    }
docs: MultithreaderMapRunner.