Last active
December 3, 2017 18:05
-
-
Save chathurangat/e02a619e27d131720211ffd9c9d300f9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Application | |
{ | |
public static void main(String[] args) throws Exception | |
{ | |
System.out.println(" main thread has started "); | |
CountDownLatch countDownLatch = new CountDownLatch(4); | |
WorkerThread workerThread1 = new WorkerThread("thread1", countDownLatch); | |
WorkerThread workerThread2 = new WorkerThread("thread2", countDownLatch); | |
WorkerThread workerThread3 = new WorkerThread("thread3", countDownLatch); | |
WorkerThread workerThread4 = new WorkerThread("thread4", countDownLatch); | |
new Thread(workerThread1).start(); | |
new Thread(workerThread2).start(); | |
new Thread(workerThread3).start(); | |
new Thread(workerThread4).start(); | |
System.out.println(" all the worker threads have been started. next calling await() method "); | |
countDownLatch.await(); | |
System.out.println(" Resume the main thread after executing all worker threads"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment