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.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.