How do I kill an Android thread completely?

后端 未结 5 427
灰色年华
灰色年华 2020-12-03 01:20

I have a service that has its own thread running on background. I\'d like to kill that service including the thread.

I created the thread like this and run it.

5条回答
  •  离开以前
    2020-12-03 01:31

    @Override
        protected void onDestroy() {
            // TODO Auto-generated method stub
            super.onDestroy();
            Thread.currentThread().interrupt();
        }
    

提交回复
热议问题