Examples of ThreadlocalPool


Examples of org.jboss.ejb3.pool.ThreadlocalPool

      }
   }
  
   public void test1()
   {
      ThreadlocalPool pool = new ThreadlocalPool();
      Container container = new MockContainer();
      int maxSize = -1;
      int timeout = -1;
      pool.initialize(container, maxSize, timeout);
      BeanContext ctx = pool.get();
      pool.release(ctx);
     
      ctx = null;
     
      gc();
      assertEquals(0, pool.getRemoveCount());
      assertEquals(0, MockBean.finalizers);
     
      pool.destroy();
     
      gc();
      assertEquals(1, pool.getRemoveCount());
      assertEquals(1, MockBean.finalizers);
   }
View Full Code Here

Examples of org.jboss.ejb3.pool.ThreadlocalPool

      assertEquals(1, MockBean.finalizers);
   }

   public void testInUse1()
   {
      ThreadlocalPool pool = new ThreadlocalPool();
      Container container = new MockContainer();
      int maxSize = -1;
      int timeout = -1;
      pool.initialize(container, maxSize, timeout);

      assertEquals(0, pool.getAvailableCount());
     
      BeanContext ctx = pool.get();

      assertEquals(0, pool.getAvailableCount());

      pool.release(ctx);
      ctx = null;

      assertEquals(1, pool.getAvailableCount());

      pool.destroy();

      gc();
   }
View Full Code Here

Examples of org.jboss.ejb3.pool.ThreadlocalPool

      gc();
   }

   public void testWithThreads() throws Exception
   {
      final ThreadlocalPool pool = new ThreadlocalPool();
      Container container = new MockContainer();
      int maxSize = -1;
      int timeout = -1;
      pool.initialize(container, maxSize, timeout);
     
      Runnable r = new Runnable()
      {
         public void run()
         {
            BeanContext ctx = pool.get();
            pool.release(ctx);
           
            ctx = null;
            used++;
         }
      };
     
      Thread threads[] = new Thread[20];
      for(int i = 0; i < threads.length; i++)
      {
         threads[i] = new Thread(r);
         threads[i].start();
      }
     
      for(Thread t : threads)
      {
         t.join(1000);
      }
     
      gc();
      assertEquals(0, pool.getRemoveCount());
      assertEquals(0, MockBean.finalizers);
     
      pool.destroy();
     
      gc();
      assertEquals(20, pool.getRemoveCount());
      assertEquals(20, MockBean.finalizers);
     
      assertEquals(20, used);
   }
View Full Code Here

Examples of org.jboss.ejb3.pool.ThreadlocalPool

      assertEquals(20, used);
   }
  
   public void testMultipleWithThreads() throws Exception
   {
      final ThreadlocalPool pool = new ThreadlocalPool();
      Container container = new MockContainer();
      int maxSize = -1;
      int timeout = -1;
      pool.initialize(container, maxSize, timeout);
     
      Runnable r = new Runnable()
      {
         public void run()
         {
            for(int i = 0; i < 10; i++)
            {
               BeanContext ctx = pool.get();
               pool.release(ctx);
              
               ctx = null;
               used++;
            }
         }
      };
     
      Thread threads[] = new Thread[20];
      for(int i = 0; i < threads.length; i++)
      {
         threads[i] = new Thread(r);
         threads[i].start();
      }
     
      for(Thread t : threads)
      {
         t.join(1000);
      }
     
      gc();
      assertEquals(0, pool.getRemoveCount());
      assertEquals(0, MockBean.finalizers);
     
      pool.destroy();
     
      gc();
      assertEquals(20, pool.getRemoveCount());
      assertEquals(20, MockBean.finalizers);
     
      assertEquals(200, used);
   }
View Full Code Here

Examples of org.jboss.ejb3.pool.ThreadlocalPool

      assertEquals(200, used);
   }
  
   public void testMultipleRecursiveWithThreads() throws Exception
   {
      final ThreadlocalPool pool = new ThreadlocalPool();
      Container container = new MockContainer();
      int maxSize = -1;
      int timeout = -1;
      pool.initialize(container, maxSize, timeout);
     
      Runnable r = new Runnable()
      {
         public void run()
         {
            for(int i = 0; i < 10; i++)
            {
               BeanContext ctx = pool.get();
               BeanContext ctx2 = pool.get();
              
               pool.release(ctx2);
               ctx2 = null;
               used ++;
              
               pool.release(ctx);
               ctx = null;
               used ++;
            }
         }
      };
     
      Thread threads[] = new Thread[20];
      for(int i = 0; i < threads.length; i++)
      {
         threads[i] = new Thread(r);
         threads[i].start();
      }
     
      for(Thread t : threads)
      {
         t.join(1000);
      }
     
      gc();
      assertEquals(200, pool.getRemoveCount());
      assertEquals(200, MockBean.finalizers);
     
      pool.destroy();
     
      gc();
      assertEquals(220, pool.getRemoveCount());
      assertEquals(220, MockBean.finalizers);
     
      assertEquals(400, used);
   }
View Full Code Here

Examples of org.jboss.ejb3.pool.ThreadlocalPool

      }
   }
  
   public void test1()
   {
      ThreadlocalPool pool = new ThreadlocalPool();
      Container container = new MockContainer();
      int maxSize = -1;
      int timeout = -1;
      pool.initialize(container, maxSize, timeout);
      BeanContext ctx = pool.get();
      pool.release(ctx);
     
      ctx = null;
     
      gc();
      assertEquals(0, pool.getRemoveCount());
      assertEquals(0, MockBean.finalizers);
     
      pool.destroy();
     
      gc();
      assertEquals(1, pool.getRemoveCount());
      assertEquals(1, MockBean.finalizers);
   }
View Full Code Here

Examples of org.jboss.ejb3.pool.ThreadlocalPool

      assertEquals(1, MockBean.finalizers);
   }
  
   public void testWithThreads() throws Exception
   {
      final ThreadlocalPool pool = new ThreadlocalPool();
      Container container = new MockContainer();
      int maxSize = -1;
      int timeout = -1;
      pool.initialize(container, maxSize, timeout);
     
      Runnable r = new Runnable()
      {
         public void run()
         {
            BeanContext ctx = pool.get();
            pool.release(ctx);
           
            ctx = null;
            used++;
         }
      };
     
      Thread threads[] = new Thread[20];
      for(int i = 0; i < threads.length; i++)
      {
         threads[i] = new Thread(r);
         threads[i].start();
      }
     
      for(Thread t : threads)
      {
         t.join(1000);
      }
     
      gc();
      assertEquals(0, pool.getRemoveCount());
      assertEquals(0, MockBean.finalizers);
     
      pool.destroy();
     
      gc();
      assertEquals(20, pool.getRemoveCount());
      assertEquals(20, MockBean.finalizers);
     
      assertEquals(20, used);
   }
View Full Code Here

Examples of org.jboss.ejb3.pool.ThreadlocalPool

      assertEquals(20, used);
   }
  
   public void testMultipleWithThreads() throws Exception
   {
      final ThreadlocalPool pool = new ThreadlocalPool();
      Container container = new MockContainer();
      int maxSize = -1;
      int timeout = -1;
      pool.initialize(container, maxSize, timeout);
     
      Runnable r = new Runnable()
      {
         public void run()
         {
            for(int i = 0; i < 10; i++)
            {
               BeanContext ctx = pool.get();
               pool.release(ctx);
              
               ctx = null;
               used++;
            }
         }
      };
     
      Thread threads[] = new Thread[20];
      for(int i = 0; i < threads.length; i++)
      {
         threads[i] = new Thread(r);
         threads[i].start();
      }
     
      for(Thread t : threads)
      {
         t.join(1000);
      }
     
      gc();
      assertEquals(0, pool.getRemoveCount());
      assertEquals(0, MockBean.finalizers);
     
      pool.destroy();
     
      gc();
      assertEquals(20, pool.getRemoveCount());
      assertEquals(20, MockBean.finalizers);
     
      assertEquals(200, used);
   }
View Full Code Here

Examples of org.jboss.ejb3.pool.ThreadlocalPool

      assertEquals(200, used);
   }
  
   public void testMultipleRecursiveWithThreads() throws Exception
   {
      final ThreadlocalPool pool = new ThreadlocalPool();
      Container container = new MockContainer();
      int maxSize = -1;
      int timeout = -1;
      pool.initialize(container, maxSize, timeout);
     
      Runnable r = new Runnable()
      {
         public void run()
         {
            for(int i = 0; i < 10; i++)
            {
               BeanContext ctx = pool.get();
               BeanContext ctx2 = pool.get();
              
               pool.release(ctx2);
               ctx2 = null;
               used ++;
              
               pool.release(ctx);
               ctx = null;
               used ++;
            }
         }
      };
     
      Thread threads[] = new Thread[20];
      for(int i = 0; i < threads.length; i++)
      {
         threads[i] = new Thread(r);
         threads[i].start();
      }
     
      for(Thread t : threads)
      {
         t.join(1000);
      }
     
      gc();
      assertEquals(200, pool.getRemoveCount());
      assertEquals(200, MockBean.finalizers);
     
      pool.destroy();
     
      gc();
      assertEquals(220, pool.getRemoveCount());
      assertEquals(220, MockBean.finalizers);
     
      assertEquals(400, used);
   }
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.