Skip to content

Instantly share code, notes, and snippets.

@justinhj
Created November 12, 2019 00:55
Show Gist options
  • Save justinhj/f2dcb243fba709a4a8af9582d87f1a3e to your computer and use it in GitHub Desktop.
Save justinhj/f2dcb243fba709a4a8af9582d87f1a3e to your computer and use it in GitHub Desktop.
Custom Scala execution context
// Create a custom threadpool and execution context for Akka to use
val executor: ExecutorService = Executors.newFixedThreadPool(4, new ThreadFactory() {
override def newThread(r: Runnable): Thread = {
val t = Executors.defaultThreadFactory.newThread(r)
t.setDaemon(true)
t
}
})
implicit val akkaEc: ExecutionContext = ExecutionContext.fromExecutor(executor)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment