Examples of BasicThreadPool


Examples of org.jboss.util.threadpool.BasicThreadPool

      }
   }

   public void testCompleteTimeoutWithSpinLoop() throws Exception
   {
      BasicThreadPool pool = new BasicThreadPool();
      pool.setMaximumQueueSize(1);
      pool.setMaximumPoolSize(1);
      try
      {
         /* Test that a task with a timeout that completes within its timeout
         works as expected
         */
         TestTask task = new TestTask(HOLD_START, "test1", 0, 10*1000, Task.WAIT_NONE);
         task.setRunSleepTime(Long.MAX_VALUE);
         pool.runTask(task);
         started.wait(1);
         started.release("test1");
         stopped.wait(1);        
         completed.wait(1);
      }
      finally
      {
         pool.stop(true);
      }
   }
View Full Code Here

Examples of org.jboss.util.threadpool.BasicThreadPool

    * Basic test
    */
   public void testBasic() throws Exception
   {
      log.debug("testBasic");
      BasicThreadPool pool = new BasicThreadPool();
      try
      {
         pool.run(new TestRunnable(BASIC, "test"));
         waitFinished(1);
         HashSet expected = makeExpected(new Object[] {"test"});
         assertEquals(expected, finishedRunnables);
      }
      finally
      {
         pool.stop(true);
      }
   }
View Full Code Here

Examples of org.jboss.util.threadpool.BasicThreadPool

     
      cacheManager.registerCache(cache, ClusteredSingleSignOn.DEFAULT_CACHE_NAME);
     
      if (usePool)
      {
         BasicThreadPool pool = new BasicThreadPool();
         mbeanServer.registerMBean(pool, new ObjectName(JBossCacheSSOClusterManager.DEFAULT_THREAD_POOL_NAME));
      }
     
      // Build up an SSO infrastructure based on LOCAL_ADDRESS 
      JBossCacheSSOClusterManager localSSOManager = new JBossCacheSSOClusterManager();
View Full Code Here

Examples of org.jboss.util.threadpool.BasicThreadPool

    * Multiple Basic test
    */
   public void testMultipleBasic() throws Exception
   {
      log.debug("testMultipleBasic");
      BasicThreadPool pool = new BasicThreadPool();
      try
      {
         pool.run(new TestRunnable(BASIC, "test1"));
         pool.run(new TestRunnable(BASIC, "test2"));
         pool.run(new TestRunnable(BASIC, "test3"));
         waitFinished(3);
         HashSet expected = makeExpected(new Object[] {"test1", "test2", "test3"});
         assertEquals(expected, finishedRunnables);
      }
      finally
      {
         pool.stop(true);
      }
   }
View Full Code Here

Examples of org.jboss.util.threadpool.BasicThreadPool

    * Test pooling
    */
   public void testSimplePooling() throws Exception
   {
      log.debug("testSimplePooling");
      BasicThreadPool pool = new BasicThreadPool();
      pool.setMaximumPoolSize(1);
      try
      {
         pool.run(new TestRunnable(BASIC, "test1"));
         waitFinished(1);
         pool.run(new TestRunnable(BASIC, "test2"));
         waitFinished(2);
         assertEquals(threadNames.get("test1"), threadNames.get("test2"));
      }
      finally
      {
         pool.stop(true);
      }
   }
View Full Code Here

Examples of org.jboss.util.threadpool.BasicThreadPool

    * Test multiple pooling
    */
   public void testMultiplePooling() throws Exception
   {
      log.debug("testMultiplePooling");
      BasicThreadPool pool = new BasicThreadPool();
      try
      {
         pool.run(new TestRunnable(HOLD_START, "test1"));
         waitStarted(1);
         pool.run(new TestRunnable(BASIC, "test2"));
         waitFinished(1);
         releaseStarted("test1");
         waitFinished(2);
         assertTrue("Shouldn't run on the same thread", threadNames.get("test1").equals(threadNames.get("test2")) == false);
      }
      finally
      {
         pool.stop(true);
      }
   }
View Full Code Here

Examples of org.jboss.util.threadpool.BasicThreadPool

    * Test maximum pool
    */
   public void testMaximumPool() throws Exception
   {
      log.debug("testMaximumPool");
      BasicThreadPool pool = new BasicThreadPool();
      pool.setMaximumPoolSize(1);
      try
      {
         pool.run(new TestRunnable(HOLD_START, "test1"));
         waitStarted(1);
         pool.run(new TestRunnable(BASIC, "test2"));
         Thread.sleep(1000);
         assertEquals(0, finishedRunnables.size());
         releaseStarted("test1");
         waitFinished(2);
         assertEquals(makeExpected(new Object[] {"test1", "test2"}), finishedRunnables);
      }
      finally
      {
         pool.stop(true);
      }
   }
View Full Code Here

Examples of org.jboss.util.threadpool.BasicThreadPool

    * Test maximum cache
    */
   public void testMaximumQueue() throws Exception
   {
      log.debug("testMaximumQueue");
      BasicThreadPool pool = new BasicThreadPool();
      pool.setMaximumQueueSize(1);
      pool.setMaximumPoolSize(1);
      try
      {
         pool.run(new TestRunnable(HOLD_START, "test1"));
         waitStarted(1);
         pool.run(new TestRunnable(BASIC, "test2"));

         boolean caught = false;
         try
         {
            pool.run(new TestRunnable(BASIC, "test3"));
         }
         catch (ThreadPoolFullException expected)
         {
            caught = true;
         }
         assertTrue("Expected ThreadPoolFullException", caught);

         releaseStarted("test1");
         waitFinished(2);
         assertEquals(makeExpected(new Object[] {"test1", "test2"}), finishedRunnables);
      }
      finally
      {
         pool.stop(true);
      }
   }
View Full Code Here

Examples of org.jboss.util.threadpool.BasicThreadPool

    * Test runnable timeouts
    */
   public void testRunnableTimeout() throws Exception
   {
      log.debug("testRunnableTimeout");
      BasicThreadPool pool = new BasicThreadPool();
      pool.setMaximumQueueSize(1);
      pool.setMaximumPoolSize(1);
      try
      {
         TestRunnable test = new TestRunnable(HOLD_START, "test1", 12*1000);
         pool.run(test, 0, 10*1000);
         waitStarted(1);
         releaseStarted("test1");
         waitFinished(1);
         assertEquals(makeExpected(new Object[] {"test1"}), finishedRunnables);
      }
      finally
      {
         pool.stop(true);
      }
   }
View Full Code Here

Examples of org.jboss.util.threadpool.BasicThreadPool

    * Test runnable timeouts
    */
   public void testRunnableTimeoutWithSpinLoop() throws Exception
   {
      log.debug("testRunnableTimeoutWithSpinLoop");
      BasicThreadPool pool = new BasicThreadPool();
      pool.setMaximumQueueSize(1);
      pool.setMaximumPoolSize(1);
      try
      {
         TestRunnable test = new TestRunnable(HOLD_START, "test1", Long.MAX_VALUE);
         pool.run(test, 0, 8*1000);
         waitStarted(1);
         releaseStarted("test1");
         Thread.sleep(12*1000);
         // Run another task to validate the previous thread has been cleared
         pool.run(new TestRunnable(BASIC, "test2"));
         waitStarted(1);
         releaseStarted("test2");
         waitFinished(1);
         assertEquals(makeExpected(new Object[] {"test2"}), finishedRunnables);
      }
      finally
      {
         pool.stop(true);
      }
   }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.