Java Mailing List Archive

http://www.ant-tasks.com/

Home » Ant Developers List »

Re: Locking in Project and PropertyHelper

Stefan Bodewig

2008-06-17

Replies: Find Java Web Hosting

Author LoginPost Reply
On Tue, 17 Jun 2008, Peter Reilly <peter.kitt.reilly@(protected):

> On Tue, Jun 17, 2008 at 1:57 PM, Stefan Bodewig <bodewig@(protected):
> > On Tue, 17 Jun 2008, Stefan Bodewig <bodewig@(protected):
> >
> >> I suggest the following changes:
> >>
> >> * lock the listener collection in the add/remove listener methods,
> >>  in fireMessageLogged lock the listeners, clone them, give up the
> >>  lock, work on the clone
> >
> > alternatively copy listeners on change in the add/remove cases since
> > we are probably writing far more log messages than we add or remove
> > listeners. Same would apply to the delegates in PropertyHelper.
>
> We currently do copy the listeners.

Why didn't I see that? Silly.

>   public synchronized void addBuildListener(BuildListener listener) {
>    ....
>      Vector newListeners = getBuildListeners();
>      newListeners.addElement(listener);
>      listeners = newListeners;
>
> Simply removing the lock on the project object would not help

I know and I hope I didn't sound as if I was suggesting that. I'd
introduce a dedicated lock object instead of using the project
instance here, though.

We could remove the lock in fireMessageLogged.

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@(protected)
For additional commands, e-mail: dev-help@(protected)

©2008 ant-tasks.com - Jax Systems, LLC, U.S.A.