/** * @param ev * @return */ private final void incrementSyncCounter(Event ev, boolean doNotBlock) { final Object source = ev._ev.getSource(); SynchronizedLimitedInt sli; synchronized (_sourcesEventCount) { // NOTE: hash code of source should not change !!! sli = (SynchronizedLimitedInt) _sourcesEventCount.get(source); if (sli == null) { _sourcesEventCount.put(source, new SynchronizedLimitedInt(1, _limit)); return; } } // this will block when limit is reached // (NOTE: it might happen that sli is removed/destroyed here) sli.increment(doNotBlock); }