public boolean tryIncrementCounter() { return barrier.tryWithWrite(new Runnable() { @Override public void run() { counter++; } }, 20, TimeUnit.MILLISECONDS); }
public boolean tryIncrementCounterHard() { return barrier.tryWithWrite(new Runnable() { @Override public void run() { counter = getCounter() + 1; } }, 20, TimeUnit.MILLISECONDS); }
public Boolean invoke() { if (System.currentTimeMillis() - lastCheck >= checkInterval) barrier.tryWithWrite(checker, updateTimeout, TimeUnit.MILLISECONDS); // And, now, back to code within the read lock. try { return handler.service(request, response); } catch (IOException ex) { exceptionHolder.put(ex); return false; } } };