技術的には同じコードスニペットを2つ持っていますが、2つ目は1秒後に最初のスニペットをとります。最初のものは、(上記のいずれか6Sを取り、次に第二のコードが一貫1S以上を要する理由7S Here is the link to codeCompletableFutureに時間がかかります - Java 8
CompletableFuture<Double> earlyEarningsInHomeCountryCF = currencyConvCF.thenApplyAsync(currencyConv -> {
Double yearlyEarnings = employmentService.getYearlyEarningForUserWithEmployer(userId, emp.getId());
return currencyConv * yearlyEarnings;
});
が教えてくださいとる6秒で実行し、7
Double yearlyEarnings = employmentService.getYearlyEarningForUserWithEmployer(userId, emp.getId());
CompletableFuture<Double> earlyEarningsInHomeCountryCF = currencyConvCF.thenApplyAsync(currencyConv -> {
return currencyConv * yearlyEarnings;
});
第二以下は、最初の
に比べて余分な時間が)メソッドの署名であるgetYearlyEarningForUserWithEmployer。ただ、共有するが、それは任意の
Double getYearlyEarningForUserWithEmployer(long userId, long employerId);
employService.getYearlyEarningForUserWithEmployer()のスニペットを与えることができます – Naruto
どのように違いがありますか? – Robin
[mcve]を作成してください。 – Tunaki