Saturday, May 2, 2009

Summary of some important Classes and Interfaces in java.util.concurrent package

Runnable
Intended to be more or less equivalent to starting a Thread. It defines a method that does not return anything and cannot throw checked exceptions.

Callable
A more flexible variant of the same idea. It defines a method that can return a value and throw a checked exception.

Future
Represents the result of a computation (e.g. a Callable). It is used in place of a value that may not be computed yet.

Executor
Accepts Runnables and returns void.

ExecutorService
Extends Executor to also provide a method that accepts a Callable and returns a Future.

Executors
Provides simple methods to get common types of ExecutorService implementations.

No comments:

Post a Comment