@Test
  public void testMultipleThreads() throws Exception {
    // Spawn a bunch of threads that write to a log
    WorkerGroup group = new WorkerGroup("Workers");
    Collection<Worker> workers = new ArrayList<>();
    for (int i = 0; i < 10; i++) {
      Worker worker = new Worker("Worker " + i, group);
      workers.add(worker);
      worker.start();
    }

    for (Worker worker : workers) {
      ThreadUtils.join(worker, TIMEOUT_MILLIS);
    }

    // Merge the log files together
    Map<String, InputStream> logs = new HashMap<>();
    for (Worker worker : workers) {
      logs.put(worker.getName(), worker.getInputStream());
    }
    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw, true);
    MergeLogFiles.mergeLogFiles(logs, pw);

    // Verify that the entries are sorted
    BufferedReader br = new BufferedReader(new StringReader(sw.toString()));
    Pattern pattern = Pattern.compile("^Worker \\d+: .* VALUE: (\\d+)");
    int lastValue = -1;
    while (br.ready()) {
      String line = br.readLine();
      if (line == null) {
        break;
      }

      Matcher matcher = pattern.matcher(line);
      if (matcher.matches()) {
        int value = Integer.parseInt(matcher.group(1));
        assertThat(value).isGreaterThan(lastValue);
        lastValue = value;
      }
    }

    assertThat(lastValue).isEqualTo(999);
  }
A bunch of threads write a strictly increasing integer to log "files" stored in byte arrays.
The files are merged and the order is verified.
geode-core/src/integrationTest/java/org/apache/geode/internal/logging/MergeLogFilesIntegrationTest.java