MappedAtomicInteger { public void set(int value) { FileLock lock = lock(); try { setUnsafe(value); } finally { FileLocks.release(lock); } } MappedAtomicInteger(FileChannel channel);  MappedAtomicInteger(FileChannel channel, int position);  MappedAtomicInteger(String address);  MappedAtomicInteger(String address, int position); int addAndGet(int amount); @Override void finalize(); int get(); void set(int value); void setAndSync(int value); void sync();  }
@Test public void testSet() { MappedAtomicInteger value = getRandomStoredInteger(); int newValue = 0; while (newValue == 0 || newValue == value.get()) { newValue = Random.getInt(); } value.set(newValue); for (int i = 0; i < Random.getScaleCount(); ++i) { Assert.assertEquals(newValue, value.get()); } }