• (nodebb)

    I can think of a reason why you might do this (a security manager that checks what the stack is before permitting an exit) but it just increases the WTF factor. Please let this just be foolish cargo-cult programming…

  • Ron Fox (google)

    He wanted the exit to be asynchronous :-P

  • Harris Mirza (unregistered) in reply to Ron Fox

    Yay! Async for everything!

  • Colin Rosenthal (google)

    They had @Override in 2001?

  • wiseguy (unregistered) in reply to Harris Mirza

    well, you woudn't want your exit block your process

  • robert (unregistered) in reply to Colin Rosenthal

    my one and only thought on this

  • Charles F (unregistered) in reply to Colin Rosenthal

    Yes, this code has definitely been touched since 2001.

  • Sham (unregistered)

    Ugh Java, obviously the entire codebase is bad.

  • Ron Fox (google) in reply to Harris Mirza

    Like node.js - maybe he thought he'd have a callback invoked after the exit was complete ;-)

  • Jester (unregistered)

    "Also Spacke Zarathustra"

    You mean "Also Sprach Zarathustra"

  • Remy Porter (google) in reply to Jester

    No. I hired Zarathustra to spackle my walls to get a nice textured finish, but then I decided the ceiling needed to match, so he spacke that, too.

  • (nodebb) in reply to Charles F

    Charles F (unregistered) in reply to Colin Rosenthal 2016-07-28

    Yes, this code has definitely been touched since 2001.

    Probably just by some script that eliminated compiler warnings.

    Jester (unregistered) 2016-07-28 Reply

    "Also Spacke Zarathustra"

    I was thinking of http://www.dict.cc/?s=Spacken

    (If it was the English title of "Also sprach Zarathustra" I'd expect "Thus Spake Zarathustra" - or is this copyrighted?)

  • S. M. Artass (unregistered)

    This is actually needed in rare cases, e.g. if jvm shutdown hooks are used (Runtime.getRuntime().addShutdownHook) Threads interrupting/joining each other may lead to some shutdown hooks not being run. Calling shutdown from a different Thread may help to keep Threads from interrupting/joining each other.

  • For the birds (unregistered)

    No, birds don't System.exit(0) from eating rice. According to Snopes, they actually love it.

  • David Delbecq (google) in reply to S. M. Artass

    Relying on shutdownHooks being called or generating deadlocks during a shutdownHook is bad behaviour anyway. Moreover, shutdow hooks are already run on their own threads.

    No, I think the idea is that we only exit when there is enough CPU time available to do it :D

  • David Delbecq (google)

    I hope OP cleaned the code properly:

    Thread.currenThread().setUncaughtExceptionHandler((t,e)-> System.exit(42)); throw new KillThatBeastThrowable();

    there, all lock cleaned :)

  • Charles F (unregistered) in reply to PWolff

    Good point. Though you have to give them credit for cleaning up their compiler warnings. :-)

  • Jack (unregistered)
    PWolff:
    Probably just by some script that eliminated compiler warnings.
    The Compiler:
    Warning: System.exit not running in dedicated thread. This is bad practice because Java sucks
  • (nodebb)

    2001? So it hasn't been touched since 1968?

  • Matt Westwood (unregistered)

    Also Spank Zarathustra? Any advance?

  • Tim! (unregistered) in reply to David Delbecq

    My first thought is that maybe there's some high-priority thread that wants to finish its work before this thread tears down the process.

  • Ron Fox (google) in reply to Matt Westwood

    The only advance I have is advance warning.

  • foxyshadis (unregistered) in reply to slapout1

    No, 0x2001, as in it won't be touched until the year 8193. This is a probable reconstruction of early 21st century coding patterns by future archaeologists.

  • divVerent (unregistered)

    I was once very proud of a tool that kills other processes by attaching a thread to them that will provoke a crash by writing to NULL.

    This let me kill tasks otherwise not killable on Windows 98...

  • JC (unregistered)

    The only spec defined reason to do that (other than weird security config of the JVM) is to postpone execution waiting for a thread to call yield(). A compliant JVM doesn't have to run threads preemptively, they can run cooperatively. It's still a WTF nonetheless.

  • Alessio (unregistered) in reply to Colin Rosenthal

    Good find, annotations were not available before the end of 2004.

Leave a comment on “Exit Thread”

Log In or post as a guest

Replying to comment #:

« Return to Article