Created
July 6, 2015 11:19
-
-
Save kermitas/d125c1d6e8ff555832d5 to your computer and use it in GitHub Desktop.
ThreadFactory with configurable priority.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package akka.dispatch | |
| import java.util.concurrent.ThreadFactory | |
| /** | |
| * Composition over the [[DispatcherPrerequisites.threadFactory]] that set priority for newly created threads. | |
| * | |
| * @param newThreadPriority priority that will be set to each newly created thread | |
| * should be between Thread.MIN_PRIORITY (which is 1) and Thread.MAX_PRIORITY (which is 10) | |
| */ | |
| class PriorityThreadFactory(prerequisites: DispatcherPrerequisites, newThreadPriority: Int) extends ThreadFactory { | |
| override def newThread(r: Runnable): Thread = { | |
| val newThread = prerequisites.threadFactory.newThread(r) | |
| newThread.setPriority(newThreadPriority) | |
| newThread | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment