AccessToken () { if (isWriteActionRunningOrPending(myApplication)) { throwCannotWriteException(); } myNoWriteActionCounter.incrementAndGet(); return new AccessToken() { @Override public void finish() { myNoWriteActionCounter.decrementAndGet(); } }; }