Advertisement
Guest User

Untitled

a guest
Nov 13th, 2012
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. (defn scheduler []
  2. "Create an executor for executing fns in an own thread."
  3. (let [executor (Executors/newSingleThreadScheduledExecutor)]
  4. (fn
  5. ([k]
  6. (cond
  7. (= k :stop) (.shutdown executor)
  8. (= k :stop-now) (.shutdownNow executor)))
  9. ([k f d]
  10. (cond
  11. (= k :once) (.schedule executor f d TimeUnit/MILLISECONDS)
  12. (= k :repeat) (.scheduleAtFixedRate executor f 0 d TimeUnit/MILLISECONDS)))
  13. ([k f id d]
  14. (cond
  15. (= k :repeat) (.scheduleAtFixedRate executor f id d TimeUnit/MILLISECONDS))))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement