@SuppressWarnings("deprecation")
    public <T> void await(final ConditionEvaluationHandler<T> conditionEvaluationHandler) {
        final Duration pollDelay = conditionSettings.getPollDelay();
        final Duration maxWaitTime = conditionSettings.getMaxWaitTime();
        final Duration minWaitTime = conditionSettings.getMinWaitTime();

        final long maxTimeout = maxWaitTime.getValue();
        long pollingStartedNanos = System.nanoTime() - pollDelay.getValueInNS();

        int pollCount = 0;
        boolean succeededBeforeTimeout = false;
        ConditionEvaluationResult lastResult = null;
        Duration evaluationDuration = new Duration(0, MILLISECONDS);
        Future<ConditionEvaluationResult> currentConditionEvaluation = null;
        try {
            if (executor.isShutdown() || executor.isTerminated()) {
                throw new IllegalStateException("The executor service that Awaitility is instructed to use has been shutdown so condition evaluation cannot be performed. Is there something wrong the thread or executor configuration?");
            }

            conditionEvaluationHandler.start();
            if (!pollDelay.isZero()) {
                Thread.sleep(pollDelay.getValueInMS());
            }
            Duration pollInterval = pollDelay;
            while (maxWaitTime.compareTo(evaluationDuration) > 0) {
                pollCount = pollCount + 1;
                // Only wait for the next condition evaluation for at most what's remaining of
                Duration maxWaitTimeForThisCondition = maxWaitTime.minus(evaluationDuration);
                currentConditionEvaluation = executor.submit(new ConditionPoller(pollInterval));
                // Wait for condition evaluation to complete with "maxWaitTimeForThisCondition" or else throw TimeoutException
                lastResult = currentConditionEvaluation.get(maxWaitTimeForThisCondition.getValue(), maxWaitTimeForThisCondition.getTimeUnit());
                if (lastResult.isSuccessful() || lastResult.hasThrowable()) {
                    break;
                }
                pollInterval = conditionSettings.getPollInterval().next(pollCount, pollInterval);
                Thread.sleep(pollInterval.getValueInMS());
                evaluationDuration = calculateConditionEvaluationDuration(pollDelay, pollingStartedNanos);
            }
            evaluationDuration = calculateConditionEvaluationDuration(pollDelay, pollingStartedNanos);
            succeededBeforeTimeout = maxWaitTime.compareTo(evaluationDuration) > 0;
        } catch (TimeoutException e) {
            lastResult = new ConditionEvaluationResult(false, null, e);
        } catch (ExecutionException e) {
            lastResult = new ConditionEvaluationResult(false, e.getCause(), null);
        } catch (Throwable e) {
            lastResult = new ConditionEvaluationResult(false, e, null);
        } finally {
            if (currentConditionEvaluation != null) {
                // Cancelling future in order to avoid race-condition with last result for Hamcrest matchers
                // See https://github.com/awaitility/awaitility/issues/109
                currentConditionEvaluation.cancel(true);
            }
        }

        try {
            if (uncaughtThrowable.get() != null) {
                throw uncaughtThrowable.get();
            } else if (lastResult != null && lastResult.hasThrowable()) {
                throw lastResult.getThrowable();
            } else if (!succeededBeforeTimeout) {
                final String maxWaitTimeLowerCase = maxWaitTime.getTimeUnitAsString();
                final String message;
                String timeoutMessage = getTimeoutMessage();
                if (conditionSettings.hasAlias()) {
                    message = String.format("Condition with alias '%s' didn't complete within %s %s because %s.",
                            conditionSettings.getAlias(), maxTimeout, maxWaitTimeLowerCase, decapitalize(timeoutMessage));
                } else {
                    message = String.format("%s within %s %s.", timeoutMessage, maxTimeout, maxWaitTimeLowerCase);
                }

                Throwable cause = lastResult != null && lastResult.hasTrace() ? lastResult.getTrace() : null;
                // Not all systems support deadlock detection so ignore if ThreadMXBean & ManagementFactory is not in classpath
                if (existInCP("java.lang.management.ThreadMXBean") && existInCP("java.lang.management.ManagementFactory")) {
                    java.lang.management.ThreadMXBean bean = java.lang.management.ManagementFactory.getThreadMXBean();
                    try {
                        long[] threadIds = bean.findDeadlockedThreads();
                        if (threadIds != null) {
                            cause = new DeadlockException(threadIds);
                        }
                    } catch (UnsupportedOperationException ignored) {
                        // findDeadLockedThreads() not supported on this VM,
                        // don't init trace and move on.
                    }
                }
                throw new ConditionTimeoutException(message, cause);
            } else if (evaluationDuration.compareTo(minWaitTime) < 0) {
                String message = String.format("Condition was evaluated in %s %s which is earlier than expected " +
                                "minimum timeout %s %s", evaluationDuration.getValue(), evaluationDuration.getTimeUnit(),
                        minWaitTime.getValue(), minWaitTime.getTimeUnit());
                throw new ConditionTimeoutException(message);
            }
        } catch (Throwable e) {
            CheckedExceptionRethrower.safeRethrow(e);
        } finally {
            uncaughtThrowable.set(null);
            conditionSettings.getExecutorLifecycle().executeNormalCleanupBehavior(executor);
        }
    }
@SuppressWarnings("deprecation")
    public <T> void await(final ConditionEvaluationHandler<T> conditionEvaluationHandler) {
        final Duration pollDelay = conditionSettings.getPollDelay();
        final Duration maxWaitTime = conditionSettings.getMaxWaitTime();
        final Duration minWaitTime = conditionSettings.getMinWaitTime();

        final long maxTimeout = maxWaitTime.getValue();
        long pollingStartedNanos = System.nanoTime() - pollDelay.getValueInNS();

        int pollCount = 0;
        boolean succeededBeforeTimeout = false;
        ConditionEvaluationResult lastResult = null;
        Duration evaluationDuration = new Duration(0, MILLISECONDS);
        Future<ConditionEvaluationResult> currentConditionEvaluation = null;
        try {
            if (executor.isShutdown() || executor.isTerminated()) {
                throw new IllegalStateException("The executor service that Awaitility is instructed to use has been shutdown so condition evaluation cannot be performed. Is there something wrong the thread or executor configuration?");
            }

            conditionEvaluationHandler.start();
            if (!pollDelay.isZero()) {
                Thread.sleep(pollDelay.getValueInMS());
            }
            Duration pollInterval = pollDelay;
            while (maxWaitTime.compareTo(evaluationDuration) > 0) {
                pollCount = pollCount + 1;
                
                Duration maxWaitTimeForThisCondition = maxWaitTime.minus(evaluationDuration);
                currentConditionEvaluation = executor.submit(new ConditionPoller(pollInterval));
                
                lastResult = currentConditionEvaluation.get(maxWaitTimeForThisCondition.getValue(), maxWaitTimeForThisCondition.getTimeUnit());
                if (lastResult.isSuccessful() || lastResult.hasThrowable()) {
                    break;
                }
                pollInterval = conditionSettings.getPollInterval().next(pollCount, pollInterval);
                Thread.sleep(pollInterval.getValueInMS());
                evaluationDuration = calculateConditionEvaluationDuration(pollDelay, pollingStartedNanos);
            }
            evaluationDuration = calculateConditionEvaluationDuration(pollDelay, pollingStartedNanos);
            succeededBeforeTimeout = maxWaitTime.compareTo(evaluationDuration) > 0;
        } catch (TimeoutException e) {
            lastResult = new ConditionEvaluationResult(false, null, e);
        } catch (ExecutionException e) {
            lastResult = new ConditionEvaluationResult(false, e.getCause(), null);
        } catch (Throwable e) {
            lastResult = new ConditionEvaluationResult(false, e, null);
        } finally {
            if (currentConditionEvaluation != null) {
                
                
                currentConditionEvaluation.cancel(true);
            }
        }

        try {
            if (uncaughtThrowable.get() != null) {
                throw uncaughtThrowable.get();
            } else if (lastResult != null && lastResult.hasThrowable()) {
                throw lastResult.getThrowable();
            } else if (!succeededBeforeTimeout) {
                final String maxWaitTimeLowerCase = maxWaitTime.getTimeUnitAsString();
                final String message;
                String timeoutMessage = getTimeoutMessage();
                if (conditionSettings.hasAlias()) {
                    message = String.format("Condition with alias '%s' didn't complete within %s %s because %s.",
                            conditionSettings.getAlias(), maxTimeout, maxWaitTimeLowerCase, decapitalize(timeoutMessage));
                } else {
                    message = String.format("%s within %s %s.", timeoutMessage, maxTimeout, maxWaitTimeLowerCase);
                }

                Throwable cause = lastResult != null && lastResult.hasTrace() ? lastResult.getTrace() : null;
                
                if (existInCP("java.lang.management.ThreadMXBean") && existInCP("java.lang.management.ManagementFactory")) {
                    java.lang.management.ThreadMXBean bean = java.lang.management.ManagementFactory.getThreadMXBean();
                    try {
                        long[] threadIds = bean.findDeadlockedThreads();
                        if (threadIds != null) {
                            cause = new DeadlockException(threadIds);
                        }
                    } catch (UnsupportedOperationException ignored) {
                        
                        
                    }
                }
                throw new ConditionTimeoutException(message, cause);
            } else if (evaluationDuration.compareTo(minWaitTime) < 0) {
                String message = String.format("Condition was evaluated in %s %s which is earlier than expected " +
                                "minimum timeout %s %s", evaluationDuration.getValue(), evaluationDuration.getTimeUnit(),
                        minWaitTime.getValue(), minWaitTime.getTimeUnit());
                throw new ConditionTimeoutException(message);
            }
        } catch (Throwable e) {
            CheckedExceptionRethrower.safeRethrow(e);
        } finally {
            uncaughtThrowable.set(null);
            conditionSettings.getExecutorLifecycle().executeNormalCleanupBehavior(executor);
        }
    }
@ SuppressWarnings ( "deprecation" ) public < T > void await ( final ConditionEvaluationHandler < T > conditionEvaluationHandler ) { final Duration pollDelay = conditionSettings . getPollDelay ( ) ; final Duration maxWaitTime = conditionSettings . getMaxWaitTime ( ) ; final Duration minWaitTime = conditionSettings . getMinWaitTime ( ) ; final long maxTimeout = maxWaitTime . getValue ( ) ; long pollingStartedNanos = System . nanoTime ( ) - pollDelay . getValueInNS ( ) ; int pollCount = 0 ; boolean succeededBeforeTimeout = false ; ConditionEvaluationResult lastResult = null ; Duration evaluationDuration = new Duration ( 0 , MILLISECONDS ) ; Future < ConditionEvaluationResult > currentConditionEvaluation = null ; try { if ( executor . isShutdown ( ) || executor . isTerminated ( ) ) { throw new IllegalStateException ( "The executor service that Awaitility is instructed to use has been shutdown so condition evaluation cannot be performed. Is there something wrong the thread or executor configuration?" ) ; } conditionEvaluationHandler . start ( ) ; if ( ! pollDelay . isZero ( ) ) { Thread . sleep ( pollDelay . getValueInMS ( ) ) ; } Duration pollInterval = pollDelay ; while ( maxWaitTime . compareTo ( evaluationDuration ) > 0 ) { pollCount = pollCount + 1 ; // Only wait for the next condition evaluation for at most what's remaining of Duration maxWaitTimeForThisCondition = maxWaitTime . minus ( evaluationDuration ) ; currentConditionEvaluation = executor . submit ( new ConditionPoller ( pollInterval ) ) ; // Wait for condition evaluation to complete with "maxWaitTimeForThisCondition" or else throw TimeoutException lastResult = currentConditionEvaluation . get ( maxWaitTimeForThisCondition . getValue ( ) , maxWaitTimeForThisCondition . getTimeUnit ( ) ) ; if ( lastResult . isSuccessful ( ) || lastResult . hasThrowable ( ) ) { break ; } pollInterval = conditionSettings . getPollInterval ( ) . next ( pollCount , pollInterval ) ; Thread . sleep ( pollInterval . getValueInMS ( ) ) ; evaluationDuration = calculateConditionEvaluationDuration ( pollDelay , pollingStartedNanos ) ; } evaluationDuration = calculateConditionEvaluationDuration ( pollDelay , pollingStartedNanos ) ; succeededBeforeTimeout = maxWaitTime . compareTo ( evaluationDuration ) > 0 ; } catch ( TimeoutException e ) { lastResult = new ConditionEvaluationResult ( false , null , e ) ; } catch ( ExecutionException e ) { lastResult = new ConditionEvaluationResult ( false , e . getCause ( ) , null ) ; } catch ( Throwable e ) { lastResult = new ConditionEvaluationResult ( false , e , null ) ; } finally { if ( currentConditionEvaluation != null ) { // Cancelling future in order to avoid race-condition with last result for Hamcrest matchers // See https://github.com/awaitility/awaitility/issues/109 currentConditionEvaluation . cancel ( true ) ; } } try { if ( uncaughtThrowable . get ( ) != null ) { throw uncaughtThrowable . get ( ) ; } else if ( lastResult != null && lastResult . hasThrowable ( ) ) { throw lastResult . getThrowable ( ) ; } else if ( ! succeededBeforeTimeout ) { final String maxWaitTimeLowerCase = maxWaitTime . getTimeUnitAsString ( ) ; final String message ; String timeoutMessage = getTimeoutMessage ( ) ; if ( conditionSettings . hasAlias ( ) ) { message = String . format ( "Condition with alias '%s' didn't complete within %s %s because %s." , conditionSettings . getAlias ( ) , maxTimeout , maxWaitTimeLowerCase , decapitalize ( timeoutMessage ) ) ; } else { message = String . format ( "%s within %s %s." , timeoutMessage , maxTimeout , maxWaitTimeLowerCase ) ; } Throwable cause = lastResult != null && lastResult . hasTrace ( ) ? lastResult . getTrace ( ) : null ; // Not all systems support deadlock detection so ignore if ThreadMXBean & ManagementFactory is not in classpath if ( existInCP ( "java.lang.management.ThreadMXBean" ) && existInCP ( "java.lang.management.ManagementFactory" ) ) { java . lang . management . ThreadMXBean bean = java . lang . management . ManagementFactory . getThreadMXBean ( ) ; try { long [ ] threadIds = bean . findDeadlockedThreads ( ) ; if ( threadIds != null ) { cause = new DeadlockException ( threadIds ) ; } } catch ( UnsupportedOperationException ignored ) { // findDeadLockedThreads() not supported on this VM, // don't init trace and move on. } } throw new ConditionTimeoutException ( message , cause ) ; } else if ( evaluationDuration . compareTo ( minWaitTime ) < 0 ) { String message = String . format ( "Condition was evaluated in %s %s which is earlier than expected " + "minimum timeout %s %s" , evaluationDuration . getValue ( ) , evaluationDuration . getTimeUnit ( ) , minWaitTime . getValue ( ) , minWaitTime . getTimeUnit ( ) ) ; throw new ConditionTimeoutException ( message ) ; } } catch ( Throwable e ) { CheckedExceptionRethrower . safeRethrow ( e ) ; } finally { uncaughtThrowable . set ( null ) ; conditionSettings . getExecutorLifecycle ( ) . executeNormalCleanupBehavior ( executor ) ; } }
<p>await.</p>

@param conditionEvaluationHandler The conditionEvaluationHandler
<p > await . < / p >