A colleague pointed out the following snippet from the Log4J 2.3 code:

/** * Called to determine if the configuration has changed. */ @Override public void checkConfiguration() { final long current = System.currentTimeMillis(); if (((counter.incrementAndGet() & MASK) == 0) && (current >= nextCheck)) { LOCK.lock(); try { nextCheck = current + intervalSeconds; if (file.lastModified() > lastModified) { lastModified = file.lastModified(); for (final ConfigurationListener listener : listeners) { final Thread thread = new Thread(new ReconfigurationWorker(listener, reconfigurable)); thread.setDaemon(true); thread.start(); } } } finally { LOCK.unlock(); } }

Where counter is an AtomicInteger field, MASK is set to 0x0f and nextCheck is long .

As far as I can understand, this method checks whether or not to reload the configuration, but does so only when the counter 's value is divisible by 16 and the next configuration check period has elapsed.

Why is this bitwise AND there?