List of usage examples for java.util Collections synchronizedList
public static <T> List<T> synchronizedList(List<T> list)
From source file:fr.landel.utils.commons.tuple.AbstractImmutableGeneric.java
/** * Create a new immutable generic instance. * * @param objects// w w w . ja v a 2s .c om * the values, may be null but not the whole array, ex: * <tt>(Object[]) null</tt> */ @SafeVarargs public AbstractImmutableGeneric(final T... objects) { super(); this.all = Collections.synchronizedList(Arrays.asList(objects)); }
From source file:axiom.util.Logger.java
/** * Create a logger for a PrintStream, such as System.out. */// w w w. j a v a 2 s .c om protected Logger(PrintStream out) { init(); writer = new PrintWriter(out); canonicalName = out.toString(); // create a synchronized list for log entries since different threads may // attempt to modify the list at the same time entries = Collections.synchronizedList(new LinkedList()); }
From source file:au.org.ala.biocache.dao.JsonPersistentQueueDAOImpl.java
@PostConstruct public void init() { offlineDownloadList = Collections.synchronizedList(new ArrayList<DownloadDetailsDTO>()); File file = new File(cacheDirectory); jsonMapper.configure(org.codehaus.jackson.map.DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);//from ww w . j ava 2 s . c o m try { FileUtils.forceMkdir(file); } catch (IOException e) { logger.error("Unable to construct cache directory.", e); } refreshFromPersistent(); }
From source file:it.av.eatt.web.data.RistoranteSortableDataProvider.java
/** * /*from w ww. j ava 2s . co m*/ * @see org.apache.wicket.markup.repeater.data.IDataProvider#iterator(int, int) */ @Override public final Iterator<Ristorante> iterator(int first, int count) { return Collections.synchronizedList(new ArrayList<Ristorante>(results)).subList(first, first + count) .iterator(); }
From source file:axiom.util.FileLogger.java
/** * Create a file logger. The actual file names do have numbers appended and are * rotated every x bytes./*ww w . j av a 2s . c om*/ */ protected FileLogger(String directory, String name) { this.name = name; logdir = new File(directory); // make logdir have an absolute path in case it doesn't already if (!logdir.isAbsolute()) logdir = logdir.getAbsoluteFile(); logfile = new File(logdir, name + ".log"); if (!logdir.exists()) { logdir.mkdirs(); } // create a synchronized list for log entries since different threads may // attempt to modify the list at the same time entries = Collections.synchronizedList(new LinkedList()); lastMessage = System.currentTimeMillis(); }
From source file:it.av.youeat.web.page.manager.data.CommentsSortableDataProvider.java
/** * // www. ja va 2s.co m * @see org.apache.wicket.markup.repeater.data.IDataProvider#iterator(int, int) */ @Override public final Iterator<Comment> iterator(int first, int count) { return Collections.synchronizedList(new ArrayList<Comment>(results)).subList(first, first + count) .iterator(); }
From source file:it.av.eatt.web.data.SearchUserFriendSortableDataProvider.java
/** * //from ww w. ja v a 2 s .com * @see org.apache.wicket.markup.repeater.data.IDataProvider#iterator(int, int) */ @Override public final Iterator<Eater> iterator(int first, int count) { return Collections.synchronizedList(new ArrayList<Eater>(results)).subList(first, first + count).iterator(); }
From source file:org.apache.metron.dataloads.nonbulk.flatfile.importer.LocalSummarizer.java
public LocalSummarizer() { stateList = Collections.synchronizedList(new ArrayList<>()); }
From source file:com.springrts.springls.nat.NatHelpServer.java
public NatHelpServer() { this.msgList = Collections.synchronizedList(new LinkedList<DatagramPacket>()); this.socket = null; this.myThread = null; this.context = null; }
From source file:org.jumpmind.util.BufferedLogAppender.java
@Override protected void append(LoggingEvent event) { Object mdc = event.getMDC("engineName"); boolean addEvent = mdc != null; if (addEvent && filterText != null) { String message = (String) event.getMessage(); addEvent = message.contains(filterText); addEvent |= event.getLoggerName().contains(filterText); if (mdc != null) { addEvent |= mdc.toString().contains(filterText); }/*ww w.ja v a2 s . c om*/ } if (addEvent) { String engineName = mdc.toString(); List<LoggingEvent> list = events.get(engineName); if (list == null) { list = Collections.synchronizedList(new ArrayList<LoggingEvent>(size)); events.put(engineName, list); } list.add(event); if (list.size() > size) { list.remove(0); } } }