Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does not calling Future.get cause any issue?

I am executing a certain flow wherein I submit some task to Callable and store the output in Future<> future. In some of the cases I am not calling future.get() to retrieve the value nor am I cancelling the task. Can this cause any issue?

like image 990
Faiz Kidwai Avatar asked Feb 17 '26 23:02

Faiz Kidwai


1 Answers

I am executing a certain flow wherein I submit some task to Callable and store the output in Future<> future. In some of the cases I am not calling future.get() to retrieve the value nor am I cancelling the task. Can this cause any issue?

No it won't cause any issues. The future will be garbage collected as long as no one is holding a reference to it.

Obviously you could submit a Runnable instead of the Callable if you don't need the results from the call() method but it sounds to me like you want to programatically chose to just forget about the Callable which is fine.

like image 53
Gray Avatar answered Feb 20 '26 13:02

Gray



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!