On Thu, Mar 12, 2009 at 8:08 PM, Streets Of Boston
flyingdutc...@gmail.comwrote:
I thought that beginBroadcast() would lock the callback-list for
modification and finishBroadcast() would unlock it again. This way, N
should always be the number of items in this HashMap you were
mentioning. Am
Ah, thanks.
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?
On Mar 13, 4:53 am, Dianne Hackborn hack...@android.com wrote:
On Thu, Mar 12, 2009 at 8:08 PM, Streets Of
On Fri, Mar 13, 2009 at 7:27 AM, Streets Of Boston
flyingdutc...@gmail.comwrote:
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
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
If your callbacks are oneway, the easiest thing to do is put it all in a big
synchronized() block. Be aware though that if the callback is into the
local process, it will still be synchronous, so holding a lock while doing
this can be a problem.
Usually the safest thing is to have a handler that
Alas, this one is not a one-way interface. It expects a boolean back:
False = cancel upload of image, True = continue uploading image. It
allows the (remote) client to cancel uploads forcefully. Luckily, the
client receiving the call-back can return this answer really fast.
The client is not the
m you mean that the value of 'N 'could be larger than the
actual elements accessed by getBroadcastItem(i), i.e. HashMap changes
while looping over the 'N' items...?
For now, i'm check for null and just ignore it. The problem is that it
is very hard to reproduce. It happens on rare
7 matches
Mail list logo