Skip to content

Commit

Permalink
Use deamon thread instead of non-deamon thread which prevent JVM from…
Browse files Browse the repository at this point in the history
… exiting
  • Loading branch information
lwronski committed Nov 17, 2022
1 parent a16b465 commit d2685fa
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 d2685fa

Please sign in to comment.