Java tutorial
//package com.java2s; /* * Copyright (C) 2013 * * 52North Initiative for Geospatial Open Source Software GmbH * Contact: Andreas Wytzisk * Martin-Luther-King-Weg 24 * 48155 Muenster, Germany * info@52north.org * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ import java.util.ArrayList; import java.util.Collections; import java.util.LinkedList; import java.util.List; public class Main { /** * Constructs a new synchronized {@code List} based on a {@link LinkedList}. * * @return a synchronized List */ public static <E> List<E> synchronizedList() { return Collections.synchronizedList(new LinkedList<E>()); } /** * Constructs a new synchronized {@code List} based on a {@link ArrayList} * with the specified {@code initialCapacity}. * * @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)); } }