Code example for Condition

Methods: await

            condition = lock.newCondition();
  "Calling Vendor Addition");
            adder.add(a, b, this);
  "Awaiting signal from caller");
            condition.await(5, TimeUnit.SECONDS);
            if(result == null) {
                throw new RuntimeException("Vendor addition timed out");
            /** If the Vendor called this in the same thread*/ 
            return result;
        } catch (InterruptedException e) {
            throw new RuntimeException("Unable to compute the sum", e);
        } finally { 
    public void withResult(int result) {
        try { 
Connect your IDE to all the code out there  Get Codota for Java