java Programming Glossary: countdownlatch
Waiting for multiple SwingWorkers http://stackoverflow.com/questions/11366330/waiting-for-multiple-swingworkers workers have completed their tasks. As described here a CountDownLatch works well in this context. In the example below each worker.. import java.util.Random import java.util.concurrent.CountDownLatch import java.util.concurrent.ExecutorService import java.util.concurrent.Executors.. ActionEvent e startButton.setEnabled false CountDownLatch latch new CountDownLatch N ExecutorService executor Executors.newFixedThreadPool..
CountDownLatch vs. Semaphore http://stackoverflow.com/questions/184147/countdownlatch-vs-semaphore vs. Semaphore Is there an advantage to using java.util.concurrent.CountdownLatch.. sem.release t.start sem.acquire num_threads 2 final CountDownLatch latch new CountDownLatch num_threads for int i 0 i num_threads.. sem.acquire num_threads 2 final CountDownLatch latch new CountDownLatch num_threads for int i 0 i num_threads i Thread t new Thread..
inter thread communication in java http://stackoverflow.com/questions/2170520/inter-thread-communication-in-java kind of thing. This could mean using LinkedBlockingQueue s CountDownLatch or many many others. For an in depth examination of concurrency..
Java: Parallelizing quick sort via multi-threading http://stackoverflow.com/questions/3425126/java-parallelizing-quick-sort-via-multi-threading int MAX_THREADS Runtime.getRuntime .availableProcessors CountDownLatch doneSignal static int num_threads 1 int my_array int start end.. 1 int my_array int start end public ThreadedQuick CountDownLatch doneSignal int array int start int end this.my_array array.. storeIndex end if num_threads MAX_THREADS num_threads CountDownLatch completionSignal new CountDownLatch 1 new ThreadedQuick completionSignal..
Swing Worker Threads Not Concurrent http://stackoverflow.com/questions/3587175/swing-worker-threads-not-concurrent start working at the same time finish at the same time. A CountDownLatch is designed for this very purpose. Here's a good example using..
Java concurrency: Countdown latch vs Cyclic barrier http://stackoverflow.com/questions/4168772/java-concurrency-countdown-latch-vs-cyclic-barrier through the java.util.concurrent API and found that CountDownLatch A synchronization aid that allows one or more threads to wait..
Java Telnet Library http://stackoverflow.com/questions/5988029/java-telnet-library import java.util.concurrent.CountDownLatch import java.util.concurrent.LinkedBlockingQueue import org.apache.commons.net.telnet.EchoOptionHandler.. private final SimpleTelnetClient checker private CountDownLatch latch private String waitFor null private boolean isKeepRunning.. return getAndClearBuffer this.waitFor waitFor latch new CountDownLatch 1 try latch.await catch InterruptedException e e.printStackTrace..
|