Skip to content

Instantly share code, notes, and snippets.

@rssh
Created September 15, 2014 21:32
Show Gist options
  • Save rssh/2c854f723a34addb07ed to your computer and use it in GitHub Desktop.
Save rssh/2c854f723a34addb07ed to your computer and use it in GitHub Desktop.
jdv_article7 (java default method implementation in interface)
interface AsyncInput<T>
{
void onReceive(Acceptor<T> acceptor)
default void read(): Future<T> {
final CompletableFuture<T> promise = new CompletableFuture<>();
onReceive( x -> promise.complete(x) );
return promise;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment