Last active
September 11, 2017 14:21
-
-
Save hisui/b0af844d131c138760c8ff079e4e00a7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def waitForSIGTERM(cv: AnyRef = new Object()) { | |
Runtime.getRuntime.addShutdownHook( | |
new Thread(() => cv.synchronized(cv.notify())) | |
) | |
@tailrec | |
def loop(): Unit = try cv.synchronized(cv.wait()) | |
catch { | |
case _: InterruptedException => loop() | |
} | |
loop() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment