void () { List<T> fileAccessorsToBeDisposed; synchronized (myCacheLock) { if (myElementsToBeDisposed.isEmpty()) return; fileAccessorsToBeDisposed = new ArrayList<>(myElementsToBeDisposed); myElementsToBeDisposed.clear(); } for (T t : fileAccessorsToBeDisposed) { try { disposeAccessor(t); } catch (IOException ex) { throw new RuntimeException(ex); } } }