### Question:
Accountant implements AutoCloseable { public long getAllocatedMemory() { return locallyHeldMemory.get(); } Accountant(Accountant parent, long reservation, long maxAllocation); void releaseBytes(long size); void setLimit(long newLimit); boolean isOverLimit(); void close(); long getLimit(); long getAllocatedMemory(); long getPeakMemoryAllocation();  }### Answer:
@Test public void nested() { final Accountant parent = new Accountant(null, 0, Long.MAX_VALUE); ensureAccurateReservations(parent); assertEquals(0, parent.getAllocatedMemory()); }
@Test public void multiThread() throws InterruptedException { final Accountant parent = new Accountant(null, 0, Long.MAX_VALUE); final int numberOfThreads = 32; final int loops = 100; Thread[] threads = new Thread[numberOfThreads]; for (int i = 0; i < numberOfThreads; i++) { Thread t = new Thread() { @Override public void run() { try { for (int i = 0; i < loops; i++) { ensureAccurateReservations(parent); } } catch (Exception ex) { ex.printStackTrace(); Assert.fail(ex.getMessage()); } } }; threads[i] = t; t.start(); } for (Thread thread : threads) { thread.join(); } assertEquals(0, parent.getAllocatedMemory()); }