/** * Returns a synchronized list backed by the given list. * <p> * You must manually synchronize on the returned buffer's iterator to * avoid non-deterministic behavior: * * <pre> * List list = ListUtils.synchronizedList(myList); * synchronized (list) { * Iterator i = list.iterator(); * while (i.hasNext()) { * process (i.next()); * } * } * </pre> * * This method uses the implementation in the decorators subpackage. * * @param list the list to synchronize, must not be null * @return a synchronized list backed by the given list * @throws IllegalArgumentException if the list is null */ public static List synchronizedList(List list) { return SynchronizedList.decorate(list); }
public List subList(int fromIndex, int toIndex) { synchronized (lock) { List list = getList().subList(fromIndex, toIndex); // the lock is passed into the constructor here to ensure that the sublist is // synchronized on the same lock as the parent list return new SynchronizedList(list, lock); } }
public Object get(int index) { synchronized (lock) { return getList().get(index); } }
/** * Factory method to create a synchronized list. * * @param list the list to decorate, must not be null * @throws IllegalArgumentException if list is null */ public static List decorate(List list) { return new SynchronizedList(list); }
public Object remove(int index) { synchronized (lock) { return getList().remove(index); } }
/** * Factory method to create a synchronized list. * * @param list the list to decorate, must not be null * @throws IllegalArgumentException if list is null */ public static List decorate(List list) { return new SynchronizedList(list); }
public Object set(int index, Object object) { synchronized (lock) { return getList().set(index, object); } }
/** * Returns a synchronized list backed by the given list. * <p> * You must manually synchronize on the returned buffer's iterator to * avoid non-deterministic behavior: * * <pre> * List list = ListUtils.synchronizedList(myList); * synchronized (list) { * Iterator i = list.iterator(); * while (i.hasNext()) { * process (i.next()); * } * } * </pre> * * This method uses the implementation in the decorators subpackage. * * @param list the list to synchronize, must not be null * @return a synchronized list backed by the given list * @throws IllegalArgumentException if the list is null */ public static List synchronizedList(List list) { return SynchronizedList.decorate(list); }
public List subList(int fromIndex, int toIndex) { synchronized (lock) { List list = getList().subList(fromIndex, toIndex); // the lock is passed into the constructor here to ensure that the sublist is // synchronized on the same lock as the parent list return new SynchronizedList(list, lock); } }
/** * Factory method to create a synchronized list. * * @param list the list to decorate, must not be null * @throws IllegalArgumentException if list is null */ public static List decorate(List list) { return new SynchronizedList(list); }
public boolean addAll(int index, Collection coll) { synchronized (lock) { return getList().addAll(index, coll); } }
public List makeEmptyList() { return SynchronizedList.decorate(new ArrayList()); }
public List subList(int fromIndex, int toIndex) { synchronized (lock) { List list = getList().subList(fromIndex, toIndex); // the lock is passed into the constructor here to ensure that the sublist is // synchronized on the same lock as the parent list return new SynchronizedList(list, lock); } }
/** * Factory method to create a synchronized list. * * @param list the list to decorate, must not be null * @throws IllegalArgumentException if list is null */ public static List decorate(List list) { return new SynchronizedList(list); }
public int lastIndexOf(Object object) { synchronized (lock) { return getList().lastIndexOf(object); } }
/** * Getter for getActivities() * * @return the getActivities() */ @SuppressWarnings("unchecked") private List<ActivityCache> getActivities() { return SynchronizedList.decorate(activities); }
public List subList(int fromIndex, int toIndex) { synchronized (lock) { List list = getList().subList(fromIndex, toIndex); // the lock is passed into the constructor here to ensure that the sublist is // synchronized on the same lock as the parent list return new SynchronizedList(list, lock); } }
/** * Factory method to create a synchronized list. * * @param list the list to decorate, must not be null * @throws IllegalArgumentException if list is null */ public static List decorate(List list) { return new SynchronizedList(list); }
/** * Iterators must be manually synchronized. * <pre> * synchronized (coll) { * ListIterator it = coll.listIterator(3); * // do stuff with iterator * } * * @return an iterator that must be manually synchronized on the collection */ public ListIterator listIterator(int index) { return getList().listIterator(index); }
/** * Getter for issues * * @return the issues */ @SuppressWarnings("unchecked") private List<IssueCache> getIssues() { return SynchronizedList.decorate(issues); }