List of usage examples for java.util.concurrent LinkedBlockingQueue LinkedBlockingQueue
public LinkedBlockingQueue()
From source file:org.sbq.batch.mains.ActivityEmulator.java
private ActivityEmulator() { super();/*from w ww. ja v a 2 s.c o m*/ blockingQueue = new LinkedBlockingQueue<Runnable>(); executor = new ThreadPoolExecutor(10, 10, 0L, TimeUnit.MILLISECONDS, blockingQueue); appCtx = new AnnotationConfigApplicationContext(ActivityEmulatorConfiguration.class); userService = appCtx.getBean(UserService.class); Map<String, AtomicBoolean> writableUserStatusByLogin = new HashMap<String, AtomicBoolean>(); for (User user : userService.findAllUsers()) { writableUserStatusByLogin.put(user.getLogin(), new AtomicBoolean(false)); } userStatusByLogin = Collections.unmodifiableMap(writableUserStatusByLogin); }
From source file:edu.wpi.checksims.util.threading.ParallelAlgorithm.java
/** * @param threads Number of threads to be used for execution *//*from ww w . j av a2s .c om*/ public static void setThreadCount(int threads) { checkArgument(threads > 0, "Attempted to set number of threads to " + threads + ", but must be positive integer!"); threadCount = threads; executor.shutdown(); // Set up the executor again with the new thread count executor = new ThreadPoolExecutor(threadCount, threadCount, 1, TimeUnit.SECONDS, new LinkedBlockingQueue<>(), new ThreadPoolExecutor.AbortPolicy()); }
From source file:net.easysmarthouse.sheduler.SimpleSchedulerImpl.java
/** * Public constructor, create queue./*from www . j av a 2 s.co m*/ */ public SimpleSchedulerImpl() { taskQueue = new LinkedBlockingQueue<TaskContainer>(); cycleTasks = new LinkedList<TaskContainer>(); }
From source file:org.openscore.lang.systemtests.TriggerFlows.java
public ScoreEvent runSync(CompilationArtifact compilationArtifact, Map<String, ? extends Serializable> userInputs, Map<String, ? extends Serializable> systemProperties) { final BlockingQueue<ScoreEvent> finishEvent = new LinkedBlockingQueue<>(); ScoreEventListener finishListener = new ScoreEventListener() { @Override/*ww w.jav a 2 s .c o m*/ public void onEvent(ScoreEvent event) throws InterruptedException { finishEvent.add(event); } }; slang.subscribeOnEvents(finishListener, FINISHED_EVENT); slang.run(compilationArtifact, userInputs, systemProperties); try { ScoreEvent event = finishEvent.take(); if (event.getEventType().equals(SLANG_EXECUTION_EXCEPTION)) { LanguageEventData languageEvent = (LanguageEventData) event.getData(); throw new RuntimeException((String) languageEvent.get(LanguageEventData.EXCEPTION)); } slang.unSubscribeOnEvents(finishListener); return event; } catch (InterruptedException e) { throw new RuntimeException(e); } }
From source file:org.apache.axis2.transport.nhttp.util.BackportWorkerPool.java
public BackportWorkerPool(int core, int max, int keepAlive, int queueLength, String threadGroupName, String threadGroupId) {/*from ww w .j ava2 s . c om*/ executor = new ThreadPoolExecutor(core, max, keepAlive, TimeUnit.SECONDS, queueLength == -1 ? new LinkedBlockingQueue() : new LinkedBlockingQueue(queueLength), new BackportThreadFactory(new ThreadGroup(threadGroupName), threadGroupId)); }
From source file:com.clustercontrol.monitor.run.util.ParallelExecution.java
/** * //from ww w . ja v a 2 s. c om */ private ParallelExecution() { log.debug("init()"); int m_maxThreadPool = HinemosPropertyUtil .getHinemosPropertyNum("monitor.common.thread.pool", Long.valueOf(10)).intValue(); log.info("monitor.common.thread.pool: " + m_maxThreadPool); es = new MonitoredThreadPoolExecutor(m_maxThreadPool, m_maxThreadPool, 0L, TimeUnit.MICROSECONDS, new LinkedBlockingQueue<Runnable>(), new ThreadFactory() { private volatile int _count = 0; @Override public Thread newThread(Runnable r) { return new Thread(r, "MonitorWorker-" + _count++); } }, new ThreadPoolExecutor.AbortPolicy()); log.debug("ParallelExecution() ExecutorService is " + es.getClass().getCanonicalName()); log.debug("ParallelExecution() securityManager is " + System.getSecurityManager()); }
From source file:biospectra.utils.BlockingExecutor.java
/** * Creates a BlockingExecutor which will block and prevent further * submission to the pool when the specified queue size has been reached. * * @param poolSize the number of the threads in the pool * @param queueSize the size of the queue *//* w w w . j av a 2s . com*/ public BlockingExecutor(final int poolSize, final int queueSize) { super(poolSize, poolSize, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>()); // the semaphore is bounding both the number of tasks currently executing // and those queued up semaphore = new Semaphore(poolSize + queueSize); }
From source file:jp.realglobe.util.uploader.DelayedWatcherTest.java
/** * @throws Exception //from w w w . ja v a 2s . c om */ @Before public void setUp() throws Exception { this.directory = Files.createTempDirectory(DelayedWatcherTest.class.getSimpleName()); this.executor = Executors.newCachedThreadPool(); this.detected = new LinkedBlockingQueue<>(); }
From source file:com.devoteam.srit.xmlloader.http.SocketClientHttp.java
/** Creates a new instance of SocketClientReceiver */ public SocketClientHttp() { this.requestsSent = new LinkedBlockingQueue(); }
From source file:org.bpmscript.integration.spring.SpringSyncChannel.java
/** * @see org.bpmscript.channel.reply.ISyncService#expect(java.lang.String) *//*ww w . ja v a 2 s . c o m*/ public void expect(String id) { replies.put(id, new LinkedBlockingQueue<Object>()); }