title: What is the insertion order if I have two memory-mapped buffers mapped to the same file?
body: <p>My question is whether the OS will respect the insertion order (i.e. last written, last to disk) or the order will be unpredictable. For example:</p>
  
  <pre><code>    byte[] s1 = "Testing1!".getBytes();
      byte[] s2 = "Testing2!".getBytes();
      byte[] s3 = "Testing3!".getBytes();
  
      RandomAccessFile raf = new RandomAccessFile("test.txt", "rw");
      FileChannel fc = raf.getChannel();
      MappedByteBuffer mbb1 = fc.map(MapMode.READ_WRITE, 0, 1024 * 1024);
      mbb1.put(s1);
  
      MappedByteBuffer mbb2 = fc.map(MapMode.READ_WRITE, mbb1.position(), 1024 * 1024);
      mbb2.put(s2);
  
      MappedByteBuffer mbb3 = fc.map(MapMode.READ_WRITE, mbb1.position() + mbb2.position(), 1024 * 1024);
      mbb3.put(s3);
  
      mbb1.put(s1); // overwrite mbb2
      mbb1.put(s1); // overwrite mbb3
  
      mbb1.force(); // go to file
      mbb3.force(); // can this ever overwrite mbb1 in the file?
      mbb2.force(); // can this ever overwrite mbb1 in the file?
  </code></pre>
  
  <p>Is it always last written, last in or am I missing something here?</p>