List of usage examples for java.util.concurrent LinkedBlockingQueue LinkedBlockingQueue
public LinkedBlockingQueue()
From source file:org.obm.locator.BlockingServlet.java
@Inject private BlockingServlet() { nextResponses = new LinkedBlockingQueue<Reply>(); }
From source file:net.ymate.platform.serv.nio.support.NioSession.java
public NioSession(NioEventGroup<LISTENER> eventGroup, SelectableChannel channel) { super();/*from ww w .ja v a 2 s . c o m*/ __eventGroup = eventGroup; __writeBufferQueue = new LinkedBlockingQueue<ByteBuffer>(); // __channel = channel; }
From source file:com.rejuvenation.parse.json.JProperty.java
private void init() { mFieldSet = new HashSet<JFieldBean>(); mGenericQueue = new LinkedBlockingQueue<Class<?>>(); }
From source file:co.mafiagame.engine.executor.CommandExecutor.java
@PostConstruct public void init() { commandsMap = new HashMap<>(); commands.forEach(c -> commandsMap.put(c.commandName(), c)); singleThread = new ThreadPoolExecutor(10, 10, keepAlive, TimeUnit.MINUTES, new LinkedBlockingQueue<>()); }
From source file:com.evandroid.musica.services.BatchDownloaderService.java
public BatchDownloaderService() { super("Batch Downloader Service"); mDownloadThreadPool = new ThreadPoolExecutor(CORE_POOL_SIZE, MAXIMUM_POOL_SIZE, KEEP_ALIVE_TIME, KEEP_ALIVE_TIME_UNIT, new LinkedBlockingQueue<Runnable>()); }
From source file:org.apache.axis2.transport.base.threads.NativeWorkerPool.java
public NativeWorkerPool(int core, int max, int keepAlive, int queueLength, String threadGroupName, String threadGroupId, BlockingQueue<Runnable> queue) { if (log.isDebugEnabled()) { log.debug("Using native util.concurrent package.."); }/* w ww.j a v a2s . c o m*/ if (queue == null) { blockingQueue = (queueLength == -1 ? new LinkedBlockingQueue<Runnable>() : new LinkedBlockingQueue<Runnable>(queueLength)); } else { blockingQueue = queue; } executor = new Axis2ThreadPoolExecutor(core, max, keepAlive, TimeUnit.SECONDS, blockingQueue, new NativeThreadFactory(new ThreadGroup(threadGroupName), threadGroupId)); }
From source file:rk.java.compute.cep.ComputeService.java
/** * @param numberOfTickSources - used to build quorum for shutdown * @param eventBus - an {@link EventBus} that's used for the creation of {@link Compute} instances *//*from w w w.ja v a 2 s.c om*/ public ComputeService(final int numberOfTickSources, IPriceEventSink eventBus) { this(new LinkedBlockingQueue<IPriceTick>(), numberOfTickSources, eventBus); }
From source file:com.liferay.sync.engine.lan.session.LanSession.java
public static ExecutorService getExecutorService() { if (_queryExecutorService != null) { return _queryExecutorService; }//from w w w.j a va 2 s . c om _queryExecutorService = new ThreadPoolExecutor(PropsValues.SYNC_LAN_SESSION_QUERY_POOL_MAX_SIZE, PropsValues.SYNC_LAN_SESSION_QUERY_POOL_MAX_SIZE, 60, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>()); _queryExecutorService.allowCoreThreadTimeOut(true); return _queryExecutorService; }
From source file:de.th.wildau.dsc.sne.webserver.WebServer.java
/** * Web server / main constructor./*from w w w.ja v a2s . c om*/ * * @param startArguments */ public WebServer(String[] startArguments) { loadConfiguration(startArguments); Log.debug(Configuration.getInstance().toString()); Log.debug("Information about the OS: " + System.getProperty("os.name") + " - " + System.getProperty("os.version") + " - " + System.getProperty("os.arch")); if (Configuration.getConfig().getProxyHost() != null) { Log.debug("setup proxy configuration"); System.setProperty("http.proxyHost", Configuration.getConfig().getProxyHost()); System.setProperty("http.proxyPort", String.valueOf(Configuration.getConfig().getProxyPort())); } Log.debug("find supported scripting languages"); supportedScriptLanguages = Collections.unmodifiableList(ScriptExecutor.getSupportedScriptLanguages()); Log.debug("Supported Script Languages " + Arrays.toString(supportedScriptLanguages.toArray())); Log.info("instantiating web server"); try { ServerSocket server = new ServerSocket(Configuration.getConfig().getServerPort()); Log.debug("bound port " + Configuration.getConfig().getServerPort()); int corePoolSize = Runtime.getRuntime().availableProcessors(); int maxPoolSize = (2 * corePoolSize) + 1; Log.debug("core/max pool size: " + corePoolSize + "/" + maxPoolSize); LinkedBlockingQueue<Runnable> workerQueue = new LinkedBlockingQueue<Runnable>(); long keepAliveTime = 30; /* * keepAliveTime - If the pool currently has more than corePoolSize * threads, excess threads will be terminated if they have been idle * for more than the keepAliveTime. */ ThreadPoolExecutor threadPool = new ThreadPoolExecutor(corePoolSize, maxPoolSize, keepAliveTime, TimeUnit.SECONDS, workerQueue); threadPool.prestartAllCoreThreads(); Socket socket = null; while (true) { try { socket = server.accept(); Log.info(socket.getInetAddress().getHostName() + " client request"); threadPool.execute(new HttpHandler(socket)); Log.debug("current threads: " + threadPool.getActiveCount()); } catch (final IOException ex) { Log.error("Connection failed!", ex); } catch (final RejectedExecutionException ex) { // XXX [sne] RejectedExecutionException // http://stackoverflow.com/questions/1519725/why-does-executors-newcachedthreadpool-throw-java-util-concurrent-rejectedexecut // http://www.javamex.com/tutorials/threads/thread_pools_queues.shtml // http://stackoverflow.com/questions/2001086/how-to-make-threadpoolexecutors-submit-method-block-if-it-is-saturated Log.error("RejectedExecutionException", ex); socket.close(); } catch (final Exception ex) { Log.fatal("Unknown error!", ex); } } } catch (final IOException ex) { Log.fatal("Can not start the server!", ex); System.err.println("Can not start the server! " + ex.getMessage()); } catch (final Exception ex) { Log.fatal("Unknown error!", ex); } }
From source file:com.geecko.QuickLyric.services.BatchDownloaderService.java
public BatchDownloaderService() { super("Batch Downloader Service"); mDownloadThreadPool = new ThreadPoolExecutor(CORE_POOL_SIZE, MAXIMUM_POOL_SIZE, KEEP_ALIVE_TIME, KEEP_ALIVE_TIME_UNIT, new LinkedBlockingQueue<Runnable>()); this.dbHelper = DatabaseHelper.getInstance(this); }