private static synchronized ExecutorService getInVMExecutor() { if (threadPoolExecutor == null) { if (ActiveMQClient.getGlobalThreadPoolSize() <= -1) { threadPoolExecutor = new ThreadPoolExecutor(0, Integer.MAX_VALUE, 60L, TimeUnit.SECONDS, new SynchronousQueue<Runnable>(), ActiveMQThreadFactory.defaultThreadFactory()); } else { threadPoolExecutor = new ActiveMQThreadPoolExecutor(0, ActiveMQClient.getGlobalThreadPoolSize(), 60L, TimeUnit.SECONDS, ActiveMQThreadFactory.defaultThreadFactory()); } } return threadPoolExecutor; }
@AfterClass public static void tearDown() { System.clearProperty(ActiveMQClient.THREAD_POOL_MAX_SIZE_PROPERTY_KEY); System.clearProperty(ActiveMQClient.SCHEDULED_THREAD_POOL_SIZE_PROPERTY_KEY); ActiveMQClient.initializeGlobalThreadPoolProperties(); ActiveMQClient.clearThreadPools(); Assert.assertEquals(ActiveMQClient.DEFAULT_GLOBAL_THREAD_POOL_MAX_SIZE, ActiveMQClient.getGlobalThreadPoolSize()); }
ActiveMQClient.initializeGlobalThreadPoolProperties(); if(threadPoolMaxSizeValue == null) { threadPoolMaxSizeValue = ActiveMQClient.getGlobalThreadPoolSize();
@Test public void testCoreClientWithGlobalThreadPoolParamtersChanged() throws Exception { int originalScheduled = ActiveMQClient.getGlobalScheduledThreadPoolSize(); int originalGlobal = ActiveMQClient.getGlobalThreadPoolSize(); try { ActiveMQClient.setGlobalThreadPoolProperties(2, 1); ActiveMQClient.clearThreadPools(); ServerLocator locator = createNonHALocator(false); testCoreClient(true, locator); } finally { // restoring original value otherwise future tests would be screwed up ActiveMQClient.setGlobalThreadPoolProperties(originalGlobal, originalScheduled); ActiveMQClient.clearThreadPools(); } }