Last active
December 13, 2015 20:08
-
-
Save martintrojer/4967220 to your computer and use it in GitHub Desktop.
ThreadPoolExecutor
This file contains hidden or 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
| (def pool (java.util.concurrent.Executors/newFixedThreadPool 2)) | |
| (def l1 (java.util.concurrent.CountDownLatch. 1)) | |
| (def l2 (java.util.concurrent.CountDownLatch. 1)) | |
| (defn worker [] (.await l1) (println "l1") (.await l2) (println "done!")) | |
| (dotimes [_ 4] (.submit pool worker)) | |
| (.countDown l1) | |
| ;; l1 | |
| ;; l1 | |
| (countDown l2) | |
| ;; done! | |
| ;; l1 | |
| ;; done! | |
| ;; l1 | |
| ;; don done!e! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment