I have a list of strings (tagList) that needs to be shared between multiple threads for reading, so I create an immutable version of this file and pass it to streams, im not sure if it is thread safe, as streams only read this list so I think should this be good?
also, when I pass this unmodifialble list to streams, does it transfer one copy and share streams or create multiple copies and transfer one copy to each stream?
here is my code:
final List<String> tList = Collections.unmodifiableList(tagList);
List<Future<Void>> calls = new ArrayList<Future<Void>>();
FileStatus[] fsta = _fileSystem.listStatus(p);
for (FileStatus sta : fsta) {
final Path path = new Path(sta.getPath(), "data.txt");
if (!_fileSystem.exists(path)) {
continue;
}
else {
calls.add(_exec.submit(new Callable<Void>() {
@Override
public Void call() throws Exception {
filterData(path, tList);
return null;
}
}));
}
}
source
share