Advertisement
Guest User

Untitled

a guest
Apr 6th, 2015
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. (def nashorn (.getEngineByName (ScriptEngineManager.) "nashorn"))
  2. (def pool (Executors/newFixedThreadPool 4))
  3.  
  4. (def tasks (for [i (range 10)] #(my-fun %)))
  5. (def futures (.invokeAll pool tasks))
  6. (for [ftr futures]
  7. (.get ftr))
  8.  
  9. ;; There's only one nashorn engine that gets shared across the 4 threads, right?
  10. ;; What does that mean for how the work is distributed if each invocation of `my-fun` tries to execute some javascript
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement