All Downloads are FREE. Search and download functionalities are using the official Maven repository.

kyo.concurrent.scheduler.Threads.scala Maven / Gradle / Ivy

There is a newer version: 0.8.5
Show newest version
package kyo.concurrent.scheduler

import java.util.concurrent.ThreadFactory
import java.util.concurrent.atomic.AtomicInteger

object Threads {

  def apply(name: String): ThreadFactory =
    apply(name, new Thread(_))

  def apply(name: String, create: Runnable => Thread): ThreadFactory =
    new ThreadFactory {
      val nextId = new AtomicInteger
      def newThread(r: Runnable): Thread = {
        val t = create(r)
        t.setName(name + "-" + nextId.incrementAndGet)
        t.setDaemon(true)
        t
      }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy