this is not a threading problem

add 4 ClickListeners to a button, have each alert it's number, 1, 2,
3, 4... on ClickListener 2, remove the listener for 2... the next
listener that fires is 4... the ArrayList is slid down, but the
iterator is still incremented, missing #3.

On Aug 24, 4:00 am, "Nicolas Wetzel" <[EMAIL PROTECTED]> wrote:
> Hi
> dont' forget that javascript execution is monothread . I' not sure the
> trouble you describe could happen. did you  check it ?
> Nicolas W
>
> On Sun, Aug 24, 2008 at 8:10 AM, Dean S. Jones <[EMAIL PROTECTED]> wrote:
>
>
>
> > I have posted about this before, but it keeps coming back to bite me,
> > or ...  not me, but people on my projects. It needs to be addressed...
> > This issue is widespread in GWT, and also in many other frameworks.
>
> > Imagine ClickListener in Button/ButtonBase/ClickListenerCollection, is
> > an ArrayList. IF, while during dispatch, a component removes, or adds
> > a ClickListener to the ArrayList of Listeners... The Iterator
> > generally used will malfunction: depending on the order of
> > registration, or the order of execution, one listener will be skipped
> > ( in the case of remove, as the list is "slidded" down"  or missed, as
> > the list is expanded to add a new Listener, it will fire... ). The
> > only SANE conclusion I can imagine is to CLONE or copy the listener
> > list at dispatch:
>
> > public Iterator<L> iterator()
> >        {
> >                ArrayList<L> temp = new ArrayList<L>(this.m_listeners);
>
> >                return temp.iterator();
> >        }
>
> > one line of code would fix this problem. It may seem like an edge
> > case, but it comes up more than I would imagine.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" 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/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to