Example usage for java.util Collections synchronizedList

List of usage examples for java.util Collections synchronizedList

Introduction

In this page you can find the example usage for java.util Collections synchronizedList.

Prototype

public static <T> List<T> synchronizedList(List<T> list) 

Source Link

Document

Returns a synchronized (thread-safe) list backed by the specified list.

Usage

From source file:it.av.youeat.web.data.RistoranteSortableDataProvider.java

/**
 * {@inheritDoc}/*from w w w.j a va 2s.  c o m*/
 */
@Override
public final Iterator<Ristorante> iterator(int first, int count) {
    results = ristoranteService.freeTextSearch(this.pattern, first, count);
    return Collections.synchronizedList(new ArrayList<Ristorante>(results)).iterator();
}

From source file:org.jcf.graphicMessage.GraphicMessageImpl.java

public void addAllEvents(List<Event> evts) {
    Assert.notNull(evts);//from  ww w  .j a  va2s.c  o m
    if (events == null)
        setEvents(Collections.synchronizedList(new ArrayList<Event>()));
    events.addAll(evts);
}

From source file:gdsc.smlm.ij.plugins.Noise.java

public int setup(String arg, ImagePlus imp) {
    if (arg.equalsIgnoreCase("final")) {
        showResults();//w w  w . j  a  va  2 s  .  co m
    }
    if (imp == null) {
        IJ.noImage();
        return DONE;
    }
    this.imp = imp;
    results = Collections.synchronizedList(new ArrayList<double[]>(imp.getStackSize()));
    return FLAGS;
}

From source file:guru.nidi.languager.check.LinkChecker.java

public List<FindResult<String>> findBrokenLinks() {
    ExecutorService executor = Executors.newCachedThreadPool();
    final List<FindResult<String>> res = Collections.synchronizedList(new ArrayList<FindResult<String>>());
    final Set<String> urls = new HashSet<>();
    int lineNum = 1;

    for (MessageLine line : contents.subList(1, contents.size())) {
        lineNum++;/*w  w w.  j a va2s  . c o m*/
        int col = 1;
        int elemNum = 0;
        for (String element : line) {
            final Matcher matcher = LINK_PATTERN.matcher(element);
            while (matcher.find()) {
                final String url = matcher.group();
                if (!urls.contains(url)) {
                    urls.add(url);
                    executor.submit(new LinkValidator(res, url,
                            new SourcePosition(file, lineNum, col + elemNum + matcher.start())));
                }
            }
            elemNum++;
            col += element.length();
        }
    }
    executor.shutdown();
    try {
        executor.awaitTermination(20, TimeUnit.SECONDS);
    } catch (InterruptedException e) {
        //ignore
    }
    return res;
}

From source file:org.pieShare.pieShareApp.service.fileService.fileListenerService.ApacheFileWatcherService.java

public void init() {
    this.fileMonitors = new ArrayList();
    this.modifiedFiles = Collections.synchronizedList(new ArrayList<>());
}

From source file:org.opennms.core.test.MockLogAppender.java

/**
 * <p>resetEvents</p>/*from w ww .j a  va 2s. c o m*/
 */
public static void resetEvents() {
    s_events = Collections.synchronizedList(new LinkedList<LoggingEvent>());
}

From source file:org.hibernate.shards.transaction.ShardedTransactionImpl.java

public ShardedTransactionImpl(ShardedSessionImplementor ssi) {
    OpenSessionEvent osEvent = new SetupTransactionOpenSessionEvent(this);
    transactions = Collections.synchronizedList(new ArrayList<Transaction>());
    for (Shard shard : ssi.getShards()) {
        if (shard.getSession() != null) {
            transactions.add(shard.getSession().getTransaction());
        } else {// w w w .  j ava 2 s  .  c o  m
            shard.addOpenSessionEvent(osEvent);
        }
    }
}

From source file:org.rifidi.designer.library.EntityLibraryRegistry.java

/**
 * private constructor Singleton pattern.
 * /*  www  .  j  a  va  2  s  .  c  o m*/
 */
private EntityLibraryRegistry() {
    libraries = Collections.synchronizedList(new ArrayList<EntityLibrary>());
    references = Collections.synchronizedMap(new HashMap<String, EntityLibraryReference>());
    entityClasses = Collections.synchronizedList(new ArrayList<Class>());
    IExtensionRegistry registry = Platform.getExtensionRegistry();
    registry.addRegistryChangeListener(this, "org.rifidi.designer.library");
    point = registry.getExtensionPoint("org.rifidi.designer.library");
    if (point == null) {
        logger.fatal("Extension point org.rifidi.designer.library missing!!");
        return;
    }
    for (IExtension extension : point.getExtensions()) {
        fillLibraries(extension, true);
    }
    internalPoint = registry.getExtensionPoint("org.rifidi.designer.entities.internal");
    for (IExtension extension : internalPoint.getExtensions()) {
        fillInternalClasses(extension, true);
    }
}

From source file:org.rifidi.designer.services.core.cabling.CablingServiceImpl.java

/**
 * Constructor./*from  ww  w  .j  a v a2 s  .c  o m*/
 */
public CablingServiceImpl() {
    logger.debug("CablingService created");
    cableList = Collections.synchronizedList(new ArrayList<CableEntity>());
    cableChangeListeners = new ArrayList<CableChangeListener>();
    ServiceRegistry.getInstance().service(this);
}

From source file:org.goko.core.common.buffer.ByteCommandBuffer.java

/**
 * Add the current command to the stack of commands
 *///w  w  w  . ja  v a 2s. com
private void stackCurrentCommand() {
    synchronized (stackedCommands) {
        stackedCommands.add(Collections.synchronizedList(new ArrayList<Byte>(currentCommand)));
        //LOG.info("Stacking command in ByteBuffer "+GkUtils.toStringReplaceCRLF(currentCommand));
        this.currentCommand.clear();
    }
}