submit

abstract fun <T> submit(task: Callable<T>): Future<T>

Submits a value-returning task for execution and returns a Future representing the pending results of the task. The Future's get method will return the task's result upon successful completion.

If you would like to immediately block waiting for a task, you can use constructions of the form result = exec.submit(aCallable).get();

Note: The Executors class includes a set of methods that can convert some other common closure-like objects, for example, java.security.PrivilegedAction to Callable form so they can be submitted.

Return

a Future representing pending completion of the task

Parameters

task

the task to submit

the type of the task's result

Throws

if the task cannot be scheduled for execution

if the task is null


abstract fun <T> submit(task: Runnable, result: T): Future<T>

Submits a Runnable task for execution and returns a Future representing that task. The Future's get method will return the given result upon successful completion.

Return

a Future representing pending completion of the task

Parameters

task

the task to submit

result

the result to return

the type of the result

Throws

if the task cannot be scheduled for execution

if the task is null


abstract fun submit(task: Runnable): Future<*>

Submits a Runnable task for execution and returns a Future representing that task. The Future's get method will return null upon successful completion.

Return

a Future representing pending completion of the task

Parameters

task

the task to submit

Throws

if the task cannot be scheduled for execution

if the task is null