Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
import java.util.concurrent.ThreadFactory
import java.util.concurrent.atomic.AtomicInteger
class DefaultThreadFactory(name: String) extends ThreadFactory {
final private val group = Thread.currentThread.getThreadGroup
final private val threadNumber = new AtomicInteger(1)
final private def threadName = s"pool-$name-thread-${threadNumber.getAndIncrement}"
def newThread(r: Runnable): Thread = {
val t = new Thread(group, r, threadName, 0)
if (t.isDaemon) t.setDaemon(false)
if (t.getPriority != Thread.NORM_PRIORITY) t.setPriority(Thread.NORM_PRIORITY)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.