Skip to content

Instantly share code, notes, and snippets.

@brunoV
Created April 5, 2014 16:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brunoV/9994113 to your computer and use it in GitHub Desktop.
Save brunoV/9994113 to your computer and use it in GitHub Desktop.
(import '[java.util.concurrent RejectedExecutionHandler]))
(def block-policy
"When the threadpool is maxed out, submit the runnable to the pool blockingly."
(reify RejectedExecutionHandler
(rejectedExecution [this runnable thread-pool]
(try
(.put (.getQueue thread-pool) runnable)
(catch InterruptedException e
(.interrupt (.currentThread Thread)))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment