2013-04-20 16:06:32 +02:00
|
|
|
(import [concurrent.futures [ThreadPoolExecutor as-completed]]
|
|
|
|
[random [randint]]
|
|
|
|
[sh [sleep]])
|
2013-04-03 03:33:08 +02:00
|
|
|
|
|
|
|
(defn task-to-do [] (sleep (randint 1 5)))
|
|
|
|
|
|
|
|
|
|
|
|
(with-as (ThreadPoolExecutor 10) executor
|
2013-07-10 02:16:49 +02:00
|
|
|
(setv jobs (list-comp (.submit executor task-to-do) (x (range 0 10))))
|
2013-04-28 16:31:31 +02:00
|
|
|
(for (future (as-completed jobs))
|
|
|
|
(.result future)))
|