Sleep the current thread when we need to retry background job shutdown

This commit is contained in:
Samvel Abrahamyan 2019-11-05 14:54:55 +01:00
parent e17c64dfb6
commit ff75a21d4f
1 changed files with 7 additions and 0 deletions

View File

@ -421,6 +421,13 @@ private[sbt] class BackgroundThreadPool extends java.io.Closeable {
status = Stopped(Some(thread))
thread.interrupt()
case Stopped(threadOption) =>
// sleep to avoid consuming a lot of CPU
try {
Thread.sleep(10)
} catch {
case e: InterruptedException =>
Thread.currentThread().interrupt();
}
// try to interrupt again! woot!
threadOption.foreach(_.interrupt())
}