How can a thread in Android be stopped?

How can a thread in Android be stopped?
Answer
There are 2 following ways preferred to stop a thread.
  1. Create a volatile boolean variable and change its value to false and check inside the thread. volatile isRunning = false; public void run() { if(!isRunning) {return;} }
  2. Or you can use the interrupt() method which can be receive inside a thread.
14 дек. 2011 г.
 

Tìm kiếm

Back
Top