When does the main thread stop in Java?

前端 未结 7 2084
被撕碎了的回忆
被撕碎了的回忆 2020-11-27 15:06

I read this statement:

The main thread must be the last thread to finish execution. When the main thread stops, the program terminates.

7条回答
  •  北海茫月
    2020-11-27 15:49

    When the main thread stops, the program terminates.

    The program terminates when there no longer is any non-daemon thread running (or someone called System.exit). The main thread can have finished long ago.

提交回复
热议问题