Faced a project with this code:
public class IndexUpdater implements Runnable {
@Override
public void run() {
final AtomicInteger count = new AtomicInteger(0);
FindIterable<Document> iterable = mongoService.getDocuments(entryMeta, null, "guid");
iterable.forEach(new Block<Document>() {
@Override
public void apply(final Document document) {
count.incrementAndGet();
// A lot of code....
if (count.get() / 100 * 100 == count.get()) {
LOG.info(String.format("Processing: %s", count.get()));
}
}
});
}
}
Here I am interested in three lines of code:
if (count.get() / 100 * 100 == count.get()) {
LOG.info(String.format("Processing: %s", count.get()));
}
Does this condition make sense considering multithreading and the type of the AtomicInteger variable? Or is this a pointless check? Interestingly, IntellijIdea does not emphasize this construct as meaningless.