Loop.prepare() should - and can - only be called once per thread, and from within the thread.

Looper.loop() is "infinite" - this is the loop that waits for messages and processes them one by one. The loop quits when you call looper.quit().

This snippet is from HandlerThread:

public void run() {
mTid = Process.myTid();
Looper.prepare();
synchronized (this) {
mLooper = Looper.myLooper();
notifyAll();
}
Process.setThreadPriority(mPriority);
onLooperPrepared();
Looper.loop();
mTid = -1;
}


-- Kostya

26.09.2011 15:56, saex пишет:
Hi, this code inside the Thread will be executed one time? or it is
infinite like while(true)?

i=1;
new Thread()
{
  public void run()
  {
    Looper.prepare();
    i=i+1;
    Looper.loop();
  }
}.start();


--
Kostya Vasilyev

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to