gt: 					int size = size();
context: package org.eclipse.xtext.resource;
  
  import java.util.Collection;
  import java.util.Iterator;
  import java.util.List;
  import java.util.ListIterator;
  import java.util.Map;
  
  import org.eclipse.emf.common.notify.NotificationChain;
  import org.eclipse.emf.common.util.AbstractEList;
  import org.eclipse.emf.common.util.EList;
  import org.eclipse.emf.common.util.URI;
  import org.eclipse.emf.ecore.resource.Resource;
  import org.eclipse.xtext.util.concurrent.IUnitOfWork;
  
  /**
   * @author Sebastian Zarnekow - Initial contribution and API
   */
  public class SynchronizedXtextResourceSet extends XtextResourceSet implements ISynchronizable<SynchronizedXtextResourceSet> {
  	private final Object lock = new Object();
  
  	@Override
  	public Resource getResource(URI uri, boolean loadOnDemand) {
  		synchronized (lock) {
  			return super.getResource(uri, loadOnDemand);
  		}
  	}
  
  	@Override
  	public Resource createResource(URI uri) {
  		synchronized (lock) {
  			return super.createResource(uri);
  		}
  	}
  
  	// Befriend the API tooling
  	@Override
  	public EList<Resource> getResources() {
  		return super.getResources();
  	}
  	
  	@Override
  	protected void registerURI(Resource resource) {
  		synchronized (lock) {
  			super.registerURI(resource);
  		}
  	}
  	
  	@Override
  	void updateURI(Resource resource, URI old, Map<URI, Resource> uriResourceMap) {
  		synchronized (lock) {
  			super.updateURI(resource, old, uriResourceMap);
  		}
  	}
  	
  	/**
  	 * Returns a synchronization lock that works for the complete resource set.
  	 * @since 2.4
  	 */
  	/* @NonNull */
  	@Override
  	public Object getLock() {
  		return lock;
  	}
  	
  	/**
  	 * {@inheritDoc}
  	 * 
  	 * @since 2.4
  	 */
  	/* @Nullable */
  	@Override
  	public <Result> Result execute(/* @NonNull */ IUnitOfWork<Result, ? super SynchronizedXtextResourceSet> unit) throws Exception {
  		synchronized (getLock()) {
  			return unit.exec(this);
  		}
  	}
  
  	/**
  	 * @since 2.4
  	 */
  	@Override
  	protected ResourcesList createResourceList() {
  		return new ResourcesList() {
  
  			private static final long serialVersionUID = -4217297874237993194L;
  
  			@Override
  			public boolean containsAll(Collection<?> c) {
  				synchronized (lock) {
  					return super.containsAll(c);
  				}
  			}
  
  			@Override
  			public Resource set(int index, Resource object) {
  				synchronized (lock) {
  					return super.set(index, object);
  				}
  			}
  
  			@Override
  			public boolean add(Resource object) {
  				synchronized (lock) {
  					return super.add(object);
  				}
  			}
  
  			@Override
  			public void add(int index, Resource object) {
  				synchronized (lock) {
  					super.add(index, object);
  				}
  			}
  
  			@Override
  			public boolean addAll(Collection<? extends Resource> collection) {
  				synchronized (lock) {
  					return super.addAll(collection);
  				}
  			}
  
  			@Override
  			public boolean addAll(int index, Collection<? extends Resource> collection) {
  				synchronized (lock) {
  					return super.addAll(index, collection);
  				}
  			}
  
  			@Override
  			public boolean remove(Object object) {
  				synchronized (lock) {
  					return super.remove(object);
  				}
  			}
  
  			@Override
  			public boolean retainAll(Collection<?> collection) {
  				synchronized (lock) {
  					return super.retainAll(collection);
  				}
  			}
  
  			@Override
  			public void move(int index, Resource object) {
  				synchronized (lock) {
  					super.move(index, object);
  				}
  			}
  
  			@Override
  			public boolean equals(Object object) {
  				synchronized (lock) {
  					return super.equals(object);
  				}
  			}
  
  			@Override
  			public int hashCode() {
  				synchronized (lock) {
  					return super.hashCode();
  				}
  			}
  
  			@Override
  			public String toString() {
  				synchronized (lock) {
  					return super.toString();
  				}
  			}
  
  			@Override
  			public Iterator<Resource> iterator() {
  				return new SynchronizedEIterator();
  			}
  
  			class SynchronizedEIterator extends AbstractEList<Resource>.EIterator<Resource> {
  				@Override
  				public boolean hasNext() {
  					synchronized (lock) {
  						return super.hasNext();
  					}
  				}
  
  				@Override
  				public Resource next() {
  					synchronized (lock) {
  						return super.next();
  					}
  				}
  
  				@Override
  				public void remove() {
  					synchronized (lock) {
  						super.remove();
  					}
  				}
  			}
  
  			class SynchronizedEListIterator extends AbstractEList<Resource>.EListIterator<Resource> {
  
  				public SynchronizedEListIterator() {
  					super();
  				}
  
  				public SynchronizedEListIterator(int index) {
  					super(index);
  				}
  
  				@Override
  				public void add(Resource object) {
  					synchronized (lock) {
  						super.add(object);
  					}
  				}
  
  				@Override
  				public boolean hasNext() {
  					synchronized (lock) {
  						return super.hasNext();
  					}
  				}
  
  				@Override
  				public boolean hasPrevious() {
  					synchronized (lock) {
  						return super.hasPrevious();
  					}
  				}
  
  				@Override
  				public Resource next() {
  					synchronized (lock) {
  						return super.next();
  					}
  				}
  
  				@Override
  				public Resource previous() {
  					synchronized (lock) {
  						return super.previous();
  					}
  				}
  
  				@Override
  				public int previousIndex() {
  					synchronized (lock) {
  						return super.previousIndex();
  					}
  				}
  
  				@Override
  				public void remove() {
  					synchronized (lock) {
  						super.remove();
  					}
  				}
  
  				@Override
  				public void set(Resource object) {
  					synchronized (lock) {
  						super.set(object);
  					}
  				}
  			}
  
  			@Override
  			public ListIterator<Resource> listIterator() {
  				return new SynchronizedEListIterator();
  			}
  
  			@Override
  			public ListIterator<Resource> listIterator(int index) {
  				synchronized (lock) {
  