LinkedHashSet<String> theFiles;
synchronized (files) {
theFiles = files;
files = null;
}
ArrayList<String> toBeDeleted = new ArrayList<String>(theFiles);
// reverse the list to maintain previous jdk deletion order.
// Last in first deleted.
Collections.reverse(toBeDeleted);
for (String filename : toBeDeleted) {
(new File(filename)).delete();
}