Submitted by heartin on Wed, 07/10/2013 - 02:17
The interface ExecutorService extends Executor and provides methods to manage termination of an Executor and methods that can produce a Future for tracking progress of one or more asynchronous tasks. An ExecutorService can be shut down, which will cause it to reject new tasks. Method submit extends base method Executor.execute(java.lang.Runnable) by creating and returning a Future that can be used to cancel execution and/or wait for completion.
Submitted by heartin on Tue, 07/09/2013 - 19:40
A task is a logical unit of work We can execute tasks sequentially or in parallel, and threads are the mechanism by which tasks can run in parallel. In Java, a task can be a Runnable or a Callable. Executors in Java concurrency package are the best way for executing tasks in a bounded way, and it is advised not to use Thread class directly.
Submitted by heartin on Mon, 07/08/2013 - 06:44
In computer science, particularly in operating systems, a semaphore is a variable or abstract data type that provides a simple but useful abstraction for controlling access, by multiple processes, to a common resource in a parallel programming or a multi user environment. Semaphores which allow an arbitrary resource count are called counting semaphores, while semaphores which are restricted to the values 0 and 1 (or locked/unlocked, unavailable/available) are called binary semaphores.
Submitted by heartin on Thu, 07/04/2013 - 01:22
A Future interface is used to represent the result of an asynchronous computation in Java concurrency. A Future interface provides methods to check if the computation is complete, to wait for its completion, and to retrieve the result of the computation. The result is retrieved using its get method when the computation has completed, and it blocks until it is completed. Cancellation is performed by the cancel method (cancel(boolean mayInterruptIfRunning)).
Submitted by heartin on Wed, 07/03/2013 - 20:01
A latch is a synchronizer that acts as a gate by delaying the progress of threads until it reaches a particular state. Once it reaches the terminal state, it cannot change state again and hence remains open forever. CountDownLatch is a latch implementation that allows one or more threads to wait for a particular state. A counter is initialized to a positive number. The countDown method decrements the counter, and the await methods wait for the counter to reach zero or until the waiting thread is interrupted, or the wait times out.
Pages