List of usage examples for java.util.concurrent Executors newFixedThreadPool
public static ExecutorService newFixedThreadPool(int nThreads)
From source file:com.jiangge.apns4j.impl.ApnsServiceImpl.java
private ApnsServiceImpl(ApnsConfig config) { int poolSize = config.getPoolSize(); service = Executors.newFixedThreadPool(poolSize); SocketFactory factory = ApnsTools.createSocketFactory(config.getKeyStore(), config.getPassword(), KEYSTORE_TYPE, ALGORITHM, PROTOCOL); connPool = ApnsConnectionPool.newConnPool(config, factory); feedbackConn = new ApnsFeedbackConnectionImpl(config, factory); }
From source file:com.inmobi.grill.server.EventServiceImpl.java
@Override public synchronized void init(HiveConf hiveConf) { int numProcs = Runtime.getRuntime().availableProcessors(); eventHandlerPool = Executors .newFixedThreadPool(hiveConf.getInt(GrillConfConstants.EVENT_SERVICE_THREAD_POOL_SIZE, numProcs)); super.init(hiveConf); }
From source file:com.nextdoor.bender.operation.conditional.ConditionalOperation.java
public ConditionalOperation(List<Pair<FilterOperation, List<OperationProcessor>>> conditionsAndProcs, boolean filterNonMatch) { this.conditionsAndProcs = conditionsAndProcs; this.es = Executors.newFixedThreadPool(conditionsAndProcs.size()); this.filterNonMatch = filterNonMatch; }
From source file:com.mapr.synth.drive.Trails.java
@Override public void setup() { ExecutorService pool = Executors.newFixedThreadPool(1); BlockingQueue<State> q = new ArrayBlockingQueue<>(2000); input = q;/*from w ww .java 2s . c o m*/ pool.submit(new Producer(q)); speedDistribution = new AVLTreeDigest(300); noise = new Random(); speed = new Stripchart(10, 430, 460, 80, 1, 0, 0, 90); rpm = new Stripchart(10, 520, 460, 80, 1, 0, 0, 2200); throttle = new Stripchart(10, 610, 460, 80, 1, 0, 0, 100); frameRate(15); }
From source file:org.atennert.com.communication.SenderManager.java
public void init() { senderPool = Executors.newFixedThreadPool(THREAD_COUNT); }
From source file:co.cask.cdap.client.rest.RestStreamWriter.java
public RestStreamWriter(RestClient restClient, int writerPoolSize, String streamName) { this.restClient = restClient; this.streamName = streamName; this.pool = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(writerPoolSize)); }
From source file:com.autsia.socialboot.SocialBootApplicationTests.java
@Test public void performanceTest() throws Exception { final IQueue<Object> queue = hazelcastInstance.getQueue(SocialBootApplication.class.getSimpleName()); ExecutorService threadPool = Executors.newFixedThreadPool(1); threadPool.submit((Runnable) () -> { while (true) { String id = String.valueOf(ThreadLocalRandom.current().nextLong()); twitterService.consumeTweetFromExternalSystem(id, text); }// www.j a va2 s .c om }); while (queue.isEmpty()) { Thread.sleep(1000); } int countBefore = queue.size(); Thread.sleep(MEASUREMENT_DELAY); int countAfter = queue.size(); LOGGER.info("Tweets processed: {}", countAfter - countBefore); }
From source file:com.bt.aloha.batchtest.JmxScenarioExporter.java
protected static void configure(BatchTest batchTest) throws Exception { Properties properties = new Properties(); InputStream is = new FileInputStream(CONFIG_FILE); properties.load(is);/*from w ww .j a v a2s .c om*/ is.close(); batchTest.setAudioFileUri(properties.getProperty("audioFileUri", "/provisioned/behave.wav")); batchTest.setNumberOfRuns(1); batchTest.setNumberOfConcurrentStarts(1); batchTest.setMaximumScenarioCompletionWaitTimeSeconds( Integer.parseInt(properties.getProperty("maximumScenarioCompletionWaitTimeSeconds", "60"))); batchTest.setExecutorService(Executors.newFixedThreadPool(4)); addBatchScenarios(batchTest); }
From source file:com.mellanox.jxio.tests.benchmarks.DataPathTestClient.java
public DataPathTestClient(String[] args) { super(args);//from w w w . j a va 2 s. co m test_iterations = Integer.parseInt(args[7]); file_path = args[6]; results = new double[num_of_threads][test_iterations * 3]; workers = new ArrayList<FutureTask<double[]>>(num_of_threads); executor = Executors.newFixedThreadPool(num_of_threads); for (int i = 0; i < num_of_threads; i++) { ClientWorker cw = new ClientWorker(inMsg_size, outMsg_size, uri, burst_size, results[i]); workers.add(new FutureTask<double[]>(cw)); } // Create/Open file if (!file_path.equals("no_file")) { write_to_file = true; try { fstream = new FileWriter(file_path, true); out = new BufferedWriter(fstream); } catch (Exception e) { LOG.error("Error in opening the results file"); e.printStackTrace(); } } }
From source file:com.app.util.SearchResultUtil.java
public static void performSearch() throws DatabaseConnectionException, SQLException { long startTime = System.nanoTime(); ExecutorService executor = Executors.newFixedThreadPool(_THREAD_POOL_SIZE); List<Integer> userIds = UserUtil.getUserIds(true); for (int userId : userIds) { SearchResultRunnable searchResultRunnable = new SearchResultRunnable(userId); executor.execute(searchResultRunnable); }//from w w w. ja v a2 s . c om executor.shutdown(); try { executor.awaitTermination(_THREAD_TIMEOUT_SECONDS, TimeUnit.SECONDS); } catch (InterruptedException ie) { _log.error("The executor encountered an exception", ie); } long endTime = System.nanoTime(); _log.info("Performing searches for {} users took {} milliseconds", userIds.size(), (endTime - startTime) / 1000000); }