Created
October 29, 2010 18:22
-
-
Save Chouser/654062 to your computer and use it in GitHub Desktop.
LinkedBlockingQueue
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
(import '(java.util.concurrent LinkedBlockingQueue TimeUnit)) | |
(def q (LinkedBlockingQueue. 5)) | |
(future (while true | |
(println (str "took " (.take q))) | |
(Thread/sleep 500))) ; simulate slow IO | |
(doseq [x (range 10)] | |
(println (str "offering " x)) | |
(.offer q x 100 TimeUnit/SECONDS)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment