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?

- 27,410
- 9
- 53
- 103

- 463
- 5
- 26
-
No issue in that, except that you won't know when the task fails. – ernest_k Jul 13 '18 at 10:51
-
You won't know if the task failed or what the outcome of the task was. – Boris the Spider Jul 13 '18 at 10:52
-
Case where I am not getting the future value I don't need to know the execution status of the task... – Faiz Kidwai Jul 13 '18 at 11:01
2 Answers
In most cases, when you do not care the execution result of this task, it will not cause any issue.
But please notice this special function of future.get
:
Memory consistency effects: Actions taken by the asynchronous computation happen-before actions following the corresponding Future.get() in another thread.
Here is an example:
int i = 0;
and if you let
i = 1;
in the task, then read i
after future.get
, it can gurantees you get the fresh value 1
.
Without calling future.get
, you might get the obsolete value 0
.

- 27,410
- 9
- 53
- 103
I am executing a certain flow wherein I submit some task to
Callable
and store the output inFuture<>
future. In some of the cases I am not callingfuture.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.

- 115,027
- 24
- 293
- 354