How do you crash a JVM?

前端 未结 27 1484
故里飘歌
故里飘歌 2020-11-28 00:22

I was reading a book on programming skills wherein the author asks the interviewee, \"How do you crash a JVM?\" I thought that you could do so by writing an infinite for-loo

27条回答
  •  伪装坚强ぢ
    2020-11-28 01:10

    Not a crash, but closer to a crash than the accepted answer of using System.exit

    You can halt the JVM by calling

    Runtime.getRuntime().halt( status )

    According to the docs :-

    "this method does not cause shutdown hooks to be started and does not run uninvoked finalizers if finalization-on-exit has been enabled".

提交回复
热议问题