Backend API. Server-side code: this runs in a Codename One backend, not in the app on the device.

public interface Future<V>

Known subtypesAsyncResult, AsyncTask

The result of work that finishes later – on the backend, what an @Async method returns, completed when its body has run on its executor.

Type parameters

<V>
the type of the result

Methods

public abstract boolean cancel(boolean mayInterruptIfRunning)Stops the work if it has not started.
public abstract boolean isCancelled()Whether cancel cancelled the work before it ran.
public abstract boolean isDone()Whether the work has finished: completed, failed or cancelled.
public abstract V get() throws InterruptedException, ExecutionExceptionWaits for the work to finish and returns its result.
public abstract V get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutExceptionWaits up to timeout for the work to finish and returns its result.

Method details

cancel

public abstract boolean cancel(boolean mayInterruptIfRunning)
Stops the work if it has not started. Answers whether it was cancelled; work already running is not interrupted by the backend’s executors.

Parameters

mayInterruptIfRunning boolean
whether a running task may be interrupted

Returns

true when this call cancelled it

isCancelled

public abstract boolean isCancelled()
Whether cancel cancelled the work before it ran.

Returns

true when cancelled

isDone

public abstract boolean isDone()
Whether the work has finished: completed, failed or cancelled.

Returns

true once it will not change again

get

public abstract V get() throws InterruptedException, ExecutionException
Waits for the work to finish and returns its result.

Returns

the result

Throws

InterruptedException
when the waiting thread is interrupted
ExecutionException
when the work threw; Throwable.getCause is what it threw
CancellationException
when the work was cancelled

get

public abstract V get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
Waits up to timeout for the work to finish and returns its result.

Parameters

timeout long
how long to wait, in unit
unit TimeUnit
the unit of timeout

Returns

the result

Throws

InterruptedException
when the waiting thread is interrupted
ExecutionException
when the work threw
TimeoutException
when it has not finished in time
CancellationException
when the work was cancelled