Saturday, June 5, 2010

Re: [android-developers] Calling wait in AsyncTask (e.g. inside doInBackground) raises IllegalMonitorStateException

Ali Chousein wrote:
> Hi,
>
> I have two AsyncTasks running; let's say A1 and A2. A2 is manipulating
> the data produced by A1 (in fact is a typical producer-consumer
> scenario). It's very tempting to use wait() inside doInBackground()
> implementation of A2, BUT this causes an IllegalMonitorStateException.
> Is it really not possible to "wait()" inside an AsyncTask? What to do
> when you have an AsyncTask which needs to wait for something?

Rewrite the AsyncTasks. Either combine them into one, or have A1 execute
A2 when A1 is completed.

--
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

_Android Programming Tutorials_ Version 2.0 Available!

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

No comments:

Post a Comment