synchronized (ownedWindows)
synchronized (getTreeLock ())
  public Window[] getOwnedWindows()  {    Window [] trimmedList;    synchronized (ownedWindows)      {	// Windows with non-null weak references in ownedWindows.	Window [] validList = new Window [ownedWindows.size()];	Iterator e = ownedWindows.iterator();	int numValid = 0;	while (e.hasNext())	  {	    Window w = (Window)(((Reference) e.next()).get());	    if (w != null)	      validList[numValid++] = w;	    else	      // Remove null weak reference from ownedWindows.	      e.remove();	  }	if (numValid != validList.length)	  {	    trimmedList = new Window [numValid];	    System.arraycopy (validList, 0, trimmedList, 0, numValid);	  }	else	  trimmedList = validList;      }    return trimmedList;  }