Java Code Examples for java.util.concurrent.CompletionStage#thenRunAsync()

The following examples show how to use java.util.concurrent.CompletionStage#thenRunAsync() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: java-async-util   File: CompletedStage.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public CompletionStage<Void> runAfterBothAsync(final CompletionStage<?> other,
    final Runnable action) {
  Objects.requireNonNull(action);
  return other.thenRunAsync(
      this.exception == null
          ? action
          : () -> {
            throw CompletedStage.wrapIfNecessary(this.exception);
          });
}
 
Example 2
Source Project: java-async-util   File: CompletedStage.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public CompletionStage<Void> runAfterBothAsync(final CompletionStage<?> other,
    final Runnable action,
    final Executor executor) {
  Objects.requireNonNull(action);
  return other.thenRunAsync(
      this.exception == null
          ? action
          : () -> {
            throw CompletedStage.wrapIfNecessary(this.exception);
          },
      executor);
}
 
Example 3
@Test // just for code coverage. The code is tested by sync version
public void thenRunAsyncDoesNotFail() {
    CompletionStage<String> completionStage1 = createCompletionStage(VALUE);
    finish(completionStage1);

    completionStage1.thenRunAsync(() -> {
    });
}