List of usage examples for java.util Collections synchronizedList
public static <T> List<T> synchronizedList(List<T> list)
From source file:org.lightjason.agentspeak.action.builtin.math.statistic.CRandomSample.java
/** * creates the sample structure//from www . ja v a2 s. c o m * * @param p_distribution distribution object * @param p_size size of the returned values * @param p_parallel parallel flag * @return term with data */ @Nonnull private static ITerm samples(@Nonnull final AbstractRealDistribution p_distribution, final int p_size, final boolean p_parallel) { if (p_size < 2) return CRawTerm.from(p_distribution.sample()); final List<Double> l_list = Arrays.stream(p_distribution.sample(p_size)).boxed() .collect(Collectors.toList()); return CRawTerm.from(p_parallel ? Collections.synchronizedList(l_list) : l_list); }
From source file:org.kuali.rice.ksb.service.impl.BasicAuthenticationServiceImpl.java
public void registerServiceCredentials(BasicAuthenticationCredentials credentials) { synchronized (serviceCredentialsMap) { QName serviceName = new QName(credentials.getServiceNameSpaceURI(), credentials.getLocalServiceName()); List<BasicAuthenticationCredentials> credentialsList = serviceCredentialsMap.get(serviceName); if (credentialsList == null) { credentialsList = Collections.synchronizedList(new ArrayList<BasicAuthenticationCredentials>()); serviceCredentialsMap.put(serviceName, credentialsList); }/*from ww w . j a va 2s . c o m*/ credentialsList.add(credentials); } }
From source file:jp.co.ctc_g.rack.core.process.ProcessServiceImpl.java
/** * {@inheritDoc}/*w w w . j av a2 s .co m*/ */ @Override public void delete(ProcessDelete delete) { List<ProcessEntity> servers = Collections.synchronizedList(new ArrayList<ProcessEntity>()); if (Strings.isNullOrEmpty(delete.getPid())) { servers = repository.findBy(delete.getGroupId()); if (servers.isEmpty()) { throw new InternalException(ProcessServiceImpl.class, "E-PROCESS#0004", Maps.hash("groupId", delete.getGroupId())); } } else { servers.add(show(delete.getGroupId(), delete.getPid())); for (int i = 0; i < servers.size(); i++) { List<ProcessEntity> childservers = repository.findByPpid(servers.get(i).getGroupId(), servers.get(i).getPid()); if (childservers != null && !childservers.isEmpty()) { servers.addAll(childservers); } } } for (ProcessEntity sv : servers) { connector.delete(sv); repository.delete(sv.getGroupId(), sv.getPid()); } }
From source file:org.sonar.scanner.mediumtest.log.LogListenerTest.java
@Before public void prepare() throws IOException { stdOutTarget = new ByteArrayOutputStream(); stdErrTarget = new ByteArrayOutputStream(); System.setOut(new PrintStream(stdOutTarget)); System.setErr(new PrintStream(stdErrTarget)); // logger from the batch might write to it asynchronously logOutput = Collections.synchronizedList(new LinkedList<LogEvent>()); logOutputStr = new StringBuilder(); tester.start();// w ww .j av a 2 s . co m baseDir = temp.getRoot(); builder = ImmutableMap.<String, String>builder().put("sonar.task", "scan") .put("sonar.projectBaseDir", baseDir.getAbsolutePath()).put("sonar.projectKey", "com.foo.project") .put("sonar.projectName", "Foo Project").put("sonar.projectVersion", "1.0-SNAPSHOT") .put("sonar.projectDescription", "Description of Foo Project"); }
From source file:org.wso2.andes.kernel.DeliverableAndesMetadata.java
public DeliverableAndesMetadata(Slot slot, long messageID, byte[] metadata, boolean parse) { super(messageID, metadata, parse); this.slot = slot; this.timeMessageIsRead = System.currentTimeMillis(); this.channelDeliveryInfo = new ConcurrentHashMap<>(); this.messageStatus = Collections.synchronizedList(new ArrayList<MessageStatus>()); this.messageStatus.add(MessageStatus.READ); }
From source file:org.apache.tez.runtime.common.resources.MemoryDistributor.java
/** * @param numTotalInputs//w w w .j a va 2 s .co m * total number of Inputs for the task * @param numTotalOutputs * total number of Outputs for the task * @param conf * Tez specific task configuration */ public MemoryDistributor(int numTotalInputs, int numTotalOutputs, Configuration conf) { this.conf = conf; isEnabled = conf.getBoolean(TezConfiguration.TEZ_TASK_SCALE_MEMORY_ENABLED, TezConfiguration.TEZ_TASK_SCALE_MEMORY_ENABLED_DEFAULT); this.numTotalInputs = numTotalInputs; this.numTotalOutputs = numTotalOutputs; this.totalJvmMemory = Runtime.getRuntime().maxMemory(); this.requestList = Collections.synchronizedList(new LinkedList<RequestorInfo>()); LOG.info("InitialMemoryDistributor (isEnabled=" + isEnabled + ") invoked with: numInputs=" + numTotalInputs + ", numOutputs=" + numTotalOutputs + ", JVM.maxFree=" + totalJvmMemory); }
From source file:nl.strohalm.cyclos.utils.WorkerThreads.java
protected WorkerThreads(final String name, final int maxThreads, final boolean purgeOld) { this.name = name; this.maxThreads = maxThreads; threads = Collections.synchronizedList(new LinkedList<WorkerThread>()); if (purgeOld) { cleanUpTimer = new Timer("Clean up timer for " + name); final TimerTask task = new TimerTask() { @Override// w ww . j a va2 s. co m public void run() { interruptOldThreads(); } }; cleanUpTimer.scheduleAtFixedRate(task, CHECK_INTERVAL, CHECK_INTERVAL); } }
From source file:com.netflix.spinnaker.clouddriver.kubernetes.v2.description.manifest.KubernetesKind.java
protected KubernetesKind(String name, String alias, boolean isNamespaced, boolean hasClusterRelationship) { if (values == null) { values = Collections.synchronizedList(new ArrayList<>()); }// w w w. java2 s . co m this.name = name; this.alias = alias; this.isNamespaced = isNamespaced; this.hasClusterRelationship = hasClusterRelationship; this.isDynamic = false; values.add(this); }
From source file:net.wimpi.telnetd.net.ConnectionManager.java
public ConnectionManager() { m_ThreadGroup = new ThreadGroup( new StringBuffer().append(this.toString()).append("Connections").toString()); m_ClosedConnections = new Stack(); m_OpenConnections = Collections.synchronizedList(new ArrayList(100)); }
From source file:com.baifendian.swordfish.execserver.job.ProcessJob.java
public ProcessJob(Consumer<List<String>> logHandler, BooleanSupplier isCompleted, boolean isLongJob, String workDir, String jobAppId, String proxyUser, String envFile, Date startTime, int timeout, Logger logger) {//from w w w. j a va 2 s . c o m this.logHandler = logHandler; this.isCompleted = isCompleted; this.isLongJob = isLongJob; this.workDir = workDir; this.jobAppId = jobAppId; this.proxyUser = proxyUser; this.envFile = envFile; this.startTime = startTime; this.timeout = timeout; this.logger = logger; this.logs = Collections.synchronizedList(new ArrayList<>()); }