How can I know how a task finished when using java's Future class?

You could simply try to retrieve the value - the get method then either throws an exception, or returns the value.

When you call Future.get() method, there is 4 possible outcomes: You get the result value You get CancellationException - if the computation was cancelled (e.g. Future. Cancel(true) is called) You get ExecutionException - if the computation threw an exception You get InterruptedException - if the current thread was interrupted while waiting (e.g.Executor.shutdownNow() is called).

You're right, this is a far more better approach. +1 – Thomas Jungblut Jul 12 at 17:38.

I have used it in my code and the only way you can figure out if the task really completed successfully is by using get().

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions