What happens to this thread runnable at the end once it is completed?

送分小仙女□ 提交于 2019-12-01 17:38:18

The thread will end and die on its own. You don't have to end it yourself. You won't be able to restart it without creating a new Thread object. The garbage collector will handle whatever memory needs to be release. The object will stay in memory as long as you hold a reference to it. Remove the reference, and the garbage collector will remove the object just like any other.

You should look into the ExecutorService and Executors.

If its the same as regular Java then it provides some powerful thread management including shutting down all the threads at once.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!