Await is what is used to ensure proper handling of blocking forAwaitable instances.
While occasionally useful, e.g. for testing, it is recommended that you avoid Await whenever possible— instead favoring combinators and/or callbacks. Await'sresult andready methods will block the calling thread's execution until they return, which will cause performance degradation, and possibly, deadlock issues.
Await the "completed" state of anAwaitable.
Await the "completed" state of anAwaitable.
Although this method is blocking, the internal use ofblocking ensures that the underlyingExecutionContext is given an opportunity to properly manage the blocking.
WARNING: It is strongly discouraged to supply lengthy timeouts since the progress of the calling thread will be suspended—blocked—until either theAwaitable becomes ready or the timeout expires.
maximum wait time, which may be negative (no waiting is done),Duration.Inf for unbounded waiting, or a finite positive duration
theAwaitable to be awaited
theawaitable
IllegalArgumentExceptionifatMost isDuration.Undefined
InterruptedException if the current thread is interrupted while waiting
TimeoutExceptionif after waiting for the specified time thisAwaitable is still not ready
Await and return the result (of typeT) of anAwaitable.
Await and return the result (of typeT) of anAwaitable.
Although this method is blocking, the internal use ofblocking ensures that the underlyingExecutionContext is given an opportunity to properly manage the blocking.
WARNING: It is strongly discouraged to supply lengthy timeouts since the progress of the calling thread will be suspended—blocked—until either theAwaitable has a result or the timeout expires.
maximum wait time, which may be negative (no waiting is done),Duration.Inf for unbounded waiting, or a finite positive duration
theAwaitable to be awaited
the result value ifawaitable is completed within the specific maximum wait time
IllegalArgumentExceptionifatMost isDuration.Undefined
InterruptedException if the current thread is interrupted while waiting
TimeoutExceptionif after waiting for the specified timeawaitable is still not ready