Le 17/03/2010 17:29, Ulf Zibis a écrit :
Why there are 2 methods which do not use the super method, where I can't see any difference? :

    public synchronized char charAt(int index)
    public synchronized void setCharAt(int index, char ch)

Wouldn't ensureCapacity better coded as follows? :
    public void ensureCapacity(int minimumCapacity) {
        if (minimumCapacity > value.length) synchronized {
            ensureCapacity(minimumCapacity);
        }
    }
This would save the synchronization if there is nothing to do.

-Ulf




no, it doesn't work.
if some variables are not in the synchronized block,
they can be updated by one thread but this change will be not visible in another thread.

Rémi

Reply via email to