Right, instead of starting a thread he posts its body as a runnable to the
UI thread, and sleep causes an ANR.

Since he has a call to sleep, it seems that he really intends to have a
thread (perhaps using sleep as a temporary placeholder for a lengthy
operation, to be added later).

So, the worker thread needs to be started, so it really runs as a thread.

This is nstead of posting it to the UI thread, which compiles and runs
(although not as intended) because Java threads implement Runnable.

Am I making more sense now?

--
Kostya Vasilyev -- http://kmansoft.wordpress.com

23.10.2010 0:47 пользователь "TreKing" <[email protected]> написал:

2010/10/22 Kostya Vasilyev <[email protected]>


>
> Prakash is right - the thread needs to be started.
No, it doesn't. He's posting it to run on a handler which will call the run
method. The problem is that that runs on the UI thread and the Task object
is sleeping for some arbitrary time, as Dan pointed out.

>
> Now, btw, why does Thead implement Runnable in Java? Seems like a recipe
for confusion.
Yes it does.
http://developer.android.com/reference/java/lang/Thread.html

-------------------------------------------------------------------------------------------------
TreKing <http://sites.google.com/site/rezmobileapps/treking> - Chicago
transit tracking app for Android-powered devices



-- 
You received this message because you are subscribed to the Google
Groups "Android Developers"...

-- 
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