How to run a thread separate from main thread in Java?

前端 未结 5 759
被撕碎了的回忆
被撕碎了的回忆 2021-02-04 05:52

The goal is to be able to invoke execution of a separate thread from within the main class.

Some context: I have a program that must ru

5条回答
  •  清歌不尽
    2021-02-04 06:37

    I'm not altogether sure you can make a 'detached' thread in Java using the normal means of implementing Thread and kicking it off with run().

    You might need to fork a thread using Runtime.exec(), running java as wholly separate process, not as a thread.

提交回复
热议问题