public boolean update(int latestCount) {
      if (!satisfied && latestCount == expectedCount) {
        if (postConditionAssertions != null) {
          try {
            postConditionAssertions.run();
          } catch (Throwable t) {
            assertionError = new AssertionError(String.format("Assertion for '%s' failed", name), t);
          }
        }

        satisfied = true;
        return true;
      }
      return false;
    }
This method should be called in the main thread. It waits for all the conditions to occur in the other
threads and then verifies that they were in fact satisfied.
samza-yarn/src/test/java/org/apache/samza/job/yarn/util/MockContainerListener.java