List of usage examples for java.util Collections synchronizedList
public static <T> List<T> synchronizedList(List<T> list)
From source file:EarlyNotify.java
public EarlyNotify() { list = Collections.synchronizedList(new LinkedList()); }
From source file:Main.java
public static List getAllChildElements(Element parent, String name) { List elements = null;//from w w w .jav a2 s . c o m if (parent != null) { elements = Collections.synchronizedList(new ArrayList()); NodeList childNodes = parent.getChildNodes(); for (int current = 0; current < childNodes.getLength(); current++) { Node node = childNodes.item(current); if ((node instanceof Element) && node.getNodeName().equals(name)) { elements.add(node); } } } return elements; }
From source file:Main.java
/** * Constructs a new synchronized {@code List} based on a {@link ArrayList} * with the specified {@code initialCapacity}. * // w w w .j av a 2s . c o m * @param initialCapacity * the initial capacity of the array list * * @return a synchronized List */ public static <E> List<E> synchronizedList(final int initialCapacity) { return Collections.synchronizedList(new ArrayList<E>(initialCapacity)); }
From source file:Main.java
public static String[] getPerformInfo(String procName) { String[] result = new String[] { "", "", "" }; String tempString = ""; List<String[]> PMUList = Collections.synchronizedList(new ArrayList<String[]>()); int INDEX_FIRST = -1; int INDEX_CPU = INDEX_FIRST + 3; int INDEX_VSS = INDEX_FIRST + 6; int INDEX_RSS = INDEX_FIRST + 7; int INDEX_NAME = INDEX_FIRST + 10; synchronized (PMUList) { for (Iterator<String[]> iterator = PMUList.iterator(); iterator.hasNext();) { String[] item = (String[]) iterator.next(); tempString = item[INDEX_NAME]; if (tempString != null && tempString.equals(procName)) { // result = "CPU:" + item[INDEX_CPU] // + " Mem:" + item[INDEX_RSS]; result[0] = item[INDEX_RSS]; result[1] = item[INDEX_VSS]; result[2] = item[INDEX_CPU]; break; }/* w ww . j a va 2 s .co m*/ } } return result; }
From source file:Main.java
/** * Constructs a new synchronized {@code List} based on a {@link LinkedList}. * * @return a synchronized List/*from ww w. j ava 2 s. c o m*/ */ public static <E> List<E> synchronizedList() { return Collections.synchronizedList(Lists.<E>newLinkedList()); }
From source file:Main.java
public static Collection narrowSynchronizedCollection(Collection c) { if (c instanceof SortedSet) return Collections.synchronizedSortedSet((SortedSet) c); else if (c instanceof Set) return Collections.synchronizedSet((Set) c); else if (c instanceof List) return Collections.synchronizedList((List) c); else//from w w w . ja va 2s . c om return Collections.synchronizedCollection(c); }
From source file:de.betterform.xml.xforms.model.submission.RequestHeaders.java
public RequestHeaders(int headerListSize) { headers = Collections.synchronizedList(new ArrayList<RequestHeader>(headerListSize)); }
From source file:edu.cornell.mannlib.vitro.webapp.searchindex.indexing.IndexingUriFinderListBasic.java
public IndexingUriFinderListBasic(Collection<? extends IndexingUriFinder> finders) { this.finders = Collections.synchronizedList(new ArrayList<>(finders)); }
From source file:Main.java
/** * Constructs a new synchronized {@code List} based on a {@link ArrayList} * with the specified {@code initialCapacity}. * * @param initialCapacity/*from www.ja va 2 s.c o m*/ * the initial capacity of the array list * * @return a synchronized List */ public static <E> List<E> synchronizedList(int initialCapacity) { return Collections.synchronizedList(Lists.<E>newArrayListWithCapacity(initialCapacity)); }
From source file:Main.java
/** * Constructs a new synchronized {@code List} based on a {@link ArrayList} * with the specified {@code initialCapacity}. * //from w ww . j a v a 2s .c o m * @param initialCapacity * the initial capacity of the array list * * @return a synchronized List */ public static <E> List<E> synchronizedList(final int initialCapacity) { return Collections.synchronizedList(Lists.<E>newArrayListWithCapacity(initialCapacity)); }