Skip to content

Commit

Permalink
Merge pull request #606 from lwronski/use-deamon-thread
Browse files Browse the repository at this point in the history
Use daemon thread instead of non-daemon thread which prevent JVM from exiting
  • Loading branch information
valencik authored Nov 18, 2022
2 parents a16b465 + d2685fa commit 371ec5a
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions munit/jvm/src/main/scala/munit/internal/PlatformCompat.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,30 @@ import scala.concurrent.Future
import sbt.testing.Task
import sbt.testing.EventHandler
import sbt.testing.Logger

import scala.concurrent.duration.Duration
import java.util.concurrent.Executors
import java.util.concurrent.{
Executors,
ThreadFactory,
TimeUnit,
TimeoutException
}
import scala.concurrent.Promise
import scala.concurrent.ExecutionContext
import java.util.concurrent.TimeUnit
import java.util.concurrent.TimeoutException
import java.util.concurrent.atomic.AtomicInteger

object PlatformCompat {
private val sh = Executors.newSingleThreadScheduledExecutor()
private val sh = Executors.newSingleThreadScheduledExecutor(
new ThreadFactory {
val counter = new AtomicInteger
def threadNumber() = counter.incrementAndGet()
def newThread(r: Runnable) =
new Thread(r, s"munit-scheduler-${threadNumber()}") {
setDaemon(true)
setPriority(Thread.NORM_PRIORITY)
}
}
)
def executeAsync(
task: Task,
eventHandler: EventHandler,
Expand Down

0 comments on commit 371ec5a

Please sign in to comment.