List/Grid concurrent Subscribe RSS feed of category concurrent

CountDownLatch example of a more general wait/notify mechanism
In this example we shall show you how to create a CountDownLatch of a more general wait/notify mechanism. We have implemented a method, that is testWaitNotify(). The steps of the method ...

Synchronous Queue example to execute commands
private BlockingQueue workQueue = new LinkedBlockingQueue(); private Map commandQueueMap = new ConcurrentHashMap(); public SynchronousQueue addCommand(Command command) { SynchronousQueue ...

Blocking Queue example of limited connection pool
private BlockingQueue<Connection> pool = new ArrayBlockingQueue<Connection>(10); private AtomicInteger connCount = new AtomicInteger(); public Connection getConnection() ...

Blocking Queue example to execute commands
import java.util.concurrent.BlockingQueue; import java.util.concurrent.LinkedBlockingQueue; private BlockingQueue<Command> workQueue = new LinkedBlockingQueue<Command>(); ...

Reentrant Lock example of a task runner
With this example we are going to demonstrate how to implement a ReentrantLock of a task runner. The ReentrantLock is a reentrant mutual exclusion Lock with the same basic behavior ...

Reentrant ReadWriteLock example of value calculator
This is an example of how to use a ReentrantReadWriteLock of a value calculator. We have implemented a method that uses a ReadWriteLock and implements the calculate(int value), the ...

Semaphores example limiting URL connections
public class ConnectionLimiter { private final Semaphore semaphore; private ConnectionLimiter(int maxConcurrentRequests) {semaphore = new Semaphore(maxConcurrentRequests); ...

Exchanger example passing logs to a background logger
import java.util.concurrent.Exchanger; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; public class BackgroundLogger implements Runnable { static ...


