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

This commit is contained in:
Samvel Abrahamyan
2019-11-22 13:28:16 -05:00
committed by Eugene Yokota
parent 8860cf4cfd
commit fa1aad602e
@@ -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())
}