0

I want to call one method asynchronous and when it finishes, call other function.

What I did is:

    CompletableFuture.supplyAsync(lab::startProduction)
     .thenApplyAsync(this::productFinalized);

and it work! but my problem now is: I need to pass n parameter to the startProduction.

startProduction(long timer)

And I don't know which is the best way/How to do that.

Thanks.

David Gueta
  • 69
  • 1
  • 7
  • 2
    `() -> lab.startProduction(timer)`? – Tunaki Jun 02 '16 at 22:04
  • gee, you even tagged your question with “[tag:lambda]” rather than “[tag:method-reference]”… – Holger Jun 03 '16 at 10:27
  • The cited question does not answer this (unless you have maybe 10 years experience with Java?) An effective solution is: (1) code your own new class implementing Consumer; (2) construct an object of that class in the calling thread - you can pass all the parameters you want in the constructor; and (3) give that object as the argument to the CompletableFuture's `thenApply` or `thenAccept` methods. – radfast Oct 02 '18 at 23:28

0 Answers0