Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kermitas/9e212b1daf920fbdd1b8 to your computer and use it in GitHub Desktop.
Save kermitas/9e212b1daf920fbdd1b8 to your computer and use it in GitHub Desktop.
Example of usage low priority threads Akka dispatcher.
val lowPriorityThreadsDispatcherName = "low-priority-threads-dispatcher"
val lowPriorityThreadsExecutionContext = play.libs.Akka.system.dispatchers.lookup(lowPriorityThreadsDispatcherName)
Future {
require(Thread.currentThread.getPriority == Thread.MIN_PRIORITY, s"current thread's priority should be ${Thread.MIN_PRIORITY} but it is ${Thread.currentThread.getPriority}")
1 + 1 // do something that would be executed on low pririty thread
}(lowPriorityThreadsExecutionContext)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment