Menu

#217 Console wrapper must wait until process exited if ctrl-c is pressed

3.x
open
nobody
None
5
2021-10-15
2021-10-15
Alexander
No

Console wrapper must wait until process is exit when Ctrl-C is pressed.
Example (in kotlin):

import kotlin.concurrent.thread

fun main() {
    val thread = Thread.currentThread()
    Runtime.getRuntime().addShutdownHook(thread(false) {
        println("waiting")
        thread.join()
        println("done")
    })
    Thread.sleep(10_000)
    println("exiting")
}

Attachments explains better.

3 Attachments

Discussion


Log in to post a comment.

MongoDB Logo MongoDB