-
zip
Compress – Decompress files example
This is an example of how to zip and unzip a file. We have implemented the FileCompressionUtil class, that consists…
Read More » -
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…
Read More » -
concurrent
Synchronous Queue example to execute commands
private BlockingQueue workQueue = new LinkedBlockingQueue(); private Map commandQueueMap = new ConcurrentHashMap(); public SynchronousQueue addCommand(Command command) { SynchronousQueue queue =…
Read More » -
concurrent
Blocking Queue example of limited connection pool
private BlockingQueue<Connection> pool = new ArrayBlockingQueue<Connection>(10); private AtomicInteger connCount = new AtomicInteger(); public Connection getConnection() { Connection conn = pool.poll(5,…
Read More » -
concurrent
Blocking Queue example to execute commands
import java.util.concurrent.BlockingQueue; import java.util.concurrent.LinkedBlockingQueue; private BlockingQueue<Command> workQueue = new LinkedBlockingQueue<Command>(); public void addCommand(Command command) { workQueue.offer(command); } public Object call()…
Read More » -
concurrent
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…
Read More » -
concurrent
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…
Read More » -
concurrent
Semaphores example limiting URL connections
In this example we shall show you how to use a Semaphore for limiting URL connections. We have implemented a…
Read More » -
concurrent
Exchanger example passing logs to a background logger
With this example we are going to demonstrate how to create an Exchanger passing logs to a background logger. We…
Read More » -
Preferences
Store preferences to user space
This is an example of how to store Preferences to user space. The Preferences class allows applications to store and retrieve…
Read More »