Created
January 29, 2013 09:30
-
-
Save obohrer/4662995 to your computer and use it in GitHub Desktop.
Concurrency test
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
(require '[clojure.tools.logging :as log]) | |
(import '(java.util.concurrent Executors)) | |
(defn t [f expected nthreads niters] | |
(let [pool (Executors/newFixedThreadPool nthreads) | |
tasks (map (fn [t] | |
(fn [] | |
(dotimes [n niters] | |
(let [res (f)] | |
(when (not= res expected) | |
(log/info "Result is not expected : " res)))))) | |
(range nthreads))] | |
(doseq [future (.invokeAll pool tasks)] | |
(.get future)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment