0
public void method(){
   runAsyncFunction();
   return;
}

I am wondering how it would be possible to block and NOT return this function (method) until the runAsyncFunction() is complete. Is this possible in Java 8? I have read about Futures, but I am not too sure how they work yet.

lliiikk
  • 23
  • 3

1 Answers1

0

Why do you call an asynchronous function, if you do not want to have it asynchronously? For example Future only

See JavaDoc Future

public void method(){
   FutureTask<String> future=
   new FutureTask<String>(new Callable<String>() {
     public String call() {
       return searcher.search(target);
   }});
   executor.execute(future);
   while(!future.isDone()){
       Thread.sleep(100);
   }
   return;
}
Z.John
  • 111
  • 1
  • 6