My question is in regards to java loopers and also how to stop them the correct way.
Lets say i have a thread defined something like this:
class NoLooperThread extends Thread{
@Override
public void run(){
Thread.sleep(2000);
}
}
and i have another thread almost the same but with a looper:
class LooperThread extends Thread{
@Override
public void run(){
Looper.prepare();
Thread.sleep(2000);
Looper.loop();
}
}
Now if i do :
new NoLooperThread().start();
i want to know after 2 seconds this thread will potentially die but if i do:
new LooperThread().start(); the thread continues to block forever ? is my assumption correct ?
and how would i stop this thread ? i know
i need call Looper.myLooper().quit();
to stop the blocking but whats the best way to do it ? should i send a message through a handler to stop it ?
so then the purpose of Looper is two fold: it creates a message queue but also keeps a thread alive, is that assumption also correct ?
My questions come after reading SO question here