Ah, now i get it! :-)

Indeed, sendProgressCallback can be called from multiple threads. And
with your earlier explanation that the beginBroadcast does not do
locking (only a brief internal lock), it may explain the problem. In
other words, RemoteCallbackList is not thread-safe across multiple
calls to it.

I should put the broadcast code inside a 'synchronized(mCallbacks)
{ ... }' block or surround it with a ReentrantLock.
Or create mCallbacks instances for each possible thread and have my
listeners register with each of them.

Thank you very much for your help.
Have a great weekend!

On Mar 13, 12:58 pm, Dianne Hackborn <hack...@android.com> wrote:
> On Fri, Mar 13, 2009 at 7:27 AM, Streets Of Boston
> <flyingdutc...@gmail.com>wrote:
>
> > Either way, it means that the number of items in the list accessed by
> > getBroadcastItem is always equal to N.
> > The problem remains: How can getBroadcastItem(int) return null?
>
> I'm not sure what you mean by "either way" -- if you are doing this from
> multiple threads, your threads can clobber the list, which can lead to this
> kind of problem.
>
> --
> Dianne Hackborn
> Android framework engineer
> hack...@android.com
>
> Note: please don't send private questions to me, as I don't have time to
> provide private support.  All such questions should be posted on public
> forums, where I and others can see and answer them.
--~--~---------~--~----~------------~-------~--~----~
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-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to