MCPcopy Index your code
hub / github.com/BruceEckel/OnJava8-Examples / main

Method main

newio/LockingMappedFiles.java:13–24  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

11 static final int LENGTH = 0x8FFFFFF; // 128 MB
12 static FileChannel fc;
13 public static void
14 main(String[] args) throws Exception {
15 fc = new RandomAccessFile("test.dat", "rw")
16 .getChannel();
17 MappedByteBuffer out = fc.map(
18 FileChannel.MapMode.READ_WRITE, 0, LENGTH);
19 for(int i = 0; i < LENGTH; i++)
20 out.put((byte)'x');
21 new LockAndModify(out, 0, 0 + LENGTH/3);
22 new LockAndModify(
23 out, LENGTH/2, LENGTH/2 + LENGTH/4);
24 }
25 private static class LockAndModify extends Thread {
26 private ByteBuffer buff;
27 private int start, end;

Callers

nothing calls this directly

Calls 1

putMethod · 0.45

Tested by

no test coverage detected