List of usage examples for java.util.concurrent LinkedBlockingQueue LinkedBlockingQueue
public LinkedBlockingQueue(Collection<? extends E> c)
From source file:com.netflix.suro.sink.notice.QueueNotice.java
@JsonCreator public QueueNotice(@JsonProperty("length") int length, @JsonProperty("recvTimeout") long timeout) { this.queue = new LinkedBlockingQueue<E>(length > 0 ? length : DEFAULT_LENGTH); this.timeout = timeout > 0 ? timeout : DEFAULT_TIMEOUT; }
From source file:ThreadTester.java
public void testQueue(PrintStream out) throws IOException { BlockingQueue queue = new LinkedBlockingQueue(10); Producer p = new Producer(queue, out); Consumer c1 = new Consumer("Consumer 1", queue, out); Consumer c2 = new Consumer("Consumer 2", queue, out); Consumer c3 = new Consumer("Consumer 3", queue, out); Consumer c4 = new Consumer("Consumer 4", queue, out); p.start();// ww w. java 2s. co m c1.start(); c2.start(); c3.start(); c4.start(); try { MILLISECONDS.sleep(100); } catch (InterruptedException ignored) { } // Finish up with these threads p.stop(); c1.stop(); c2.stop(); c3.stop(); c4.stop(); }
From source file:com.apache.kafka.connect.solr.util.SolrServerClient.java
public SolrServerClient(final SolrConnectorConfig _config) { this._config = _config; this._batchQueue = new LinkedBlockingQueue<HashMap<String, Object>>(_config.getBulkSize()); mapper = new ObjectMapper(); }
From source file:nz.co.fortytwo.freeboard.server.SerialPortReader.java
public SerialPortReader() { super(); queue = new LinkedBlockingQueue<String>(100); }
From source file:com.joshlong.esb.springintegration.modules.nativefs.NativeFileSystemMonitor.java
public void init() { additions = new LinkedBlockingQueue<String>(this.maxQueueValue); boolean goodDirToMonitor = (directoryToMonitor.isDirectory() && directoryToMonitor.exists()); if (!goodDirToMonitor) { if (!directoryToMonitor.exists()) { if (this.autoCreateDirectory) { if (!directoryToMonitor.mkdirs()) { logger.debug(String.format("couldn't create directory %s", directoryToMonitor.getAbsolutePath())); }/* w ww.j a va2 s . c o m*/ } } } if (this.executor == null) { this.executor = new SimpleAsyncTaskExecutor(); } Assert.state(directoryToMonitor.exists(), "the directory " + directoryToMonitor.getAbsolutePath() + " doesn't exist"); }
From source file:com.handu.open.dubbo.monitor.DubboMonitorService.java
@PostConstruct private void init() { queue = new LinkedBlockingQueue<URL>( Integer.parseInt(ConfigUtils.getProperty("dubbo.monitor.queue", "100000"))); writeThread = new Thread(new Runnable() { public void run() { while (running) { try { writeToDataBase(); // } catch (Throwable t) { // logger.error("Unexpected error occur at write stat log, cause: " + t.getMessage(), t); try { Thread.sleep(5000); // } catch (Throwable t2) { }//from w ww . jav a2 s.co m } } } }); writeThread.setDaemon(true); writeThread.setName("DubboMonitorAsyncWriteLogThread"); writeThread.start(); }
From source file:com.sm.replica.server.ReplicaServerHandler.java
private void init() { if (Runtime.getRuntime().availableProcessors() > maxThreads) this.maxThreads = Runtime.getRuntime().availableProcessors(); if (maxQueue < maxThreads * 1000) maxQueue = maxThreads * 1000;//w w w. ja v a 2s . c o m BlockingQueue<Runnable> queue = new LinkedBlockingQueue<Runnable>(maxQueue); threadPools = new ThreadPoolExecutor(maxThreads, maxThreads, 30, TimeUnit.SECONDS, queue, new ThreadPoolFactory("Replica")); }
From source file:com.splout.db.dnode.CustomTThreadPoolServer.java
public CustomTThreadPoolServer(Args args) { super(args);// w ww . ja v a 2 s . c o m LinkedBlockingQueue<Runnable> executorQueue = new LinkedBlockingQueue<Runnable>(args.maxWorkerThreads); stopTimeoutUnit = args.stopTimeoutUnit; stopTimeoutVal = args.stopTimeoutVal; executorService_ = new ThreadPoolExecutor(args.minWorkerThreads, args.maxWorkerThreads, 60, TimeUnit.SECONDS, executorQueue); }
From source file:com.cloudera.branchreduce.impl.distributed.TaskMaster.java
public TaskMaster(int vassalCount, List<T> initialTasks, G globalState, ExecutorService executor) { this.vassalCount = vassalCount; this.workers = Lists.newArrayList(); this.hasWork = Maps.newConcurrentMap(); this.tasks = new LinkedBlockingQueue<T>(initialTasks); this.globalState = globalState; if (!initialTasks.isEmpty()) { this.taskClass = (Class<T>) initialTasks.get(0).getClass(); } else {/* www . jav a 2 s . co m*/ this.taskClass = null; } this.executor = executor; }