1 package org.exoplatform.services.threadpool.test; 2 3 import org.exoplatform.container.PortalContainer; 4 import org.exoplatform.services.threadpool.impl.ThreadPoolServiceImpl; 5 import org.exoplatform.test.BasicTestCase; 6 7 12 public class TestSimpleThreadPoolService extends BasicTestCase{ 13 private ThreadPoolServiceImpl service_; 14 15 private static int counter = 0; 16 17 public TestSimpleThreadPoolService(String name) { 18 super(name); 19 } 20 21 protected String getDescription() { 22 return "Test the Thread pool service"; 23 } 24 25 public void setUp() throws Exception { 26 PortalContainer manager = PortalContainer.getInstance(); 27 service_ = 28 (ThreadPoolServiceImpl) manager.getComponentInstanceOfType(ThreadPoolServiceImpl.class) ; 29 } 30 31 public void testSimpleThreadPoolService() throws InterruptedException { 32 service_.setMaximumPoolSize(10); 33 for(int i= 0; i < 20; i++){ 34 Runnable r = new SimpleRunnable(); 35 service_.execute(r); 36 } 37 } 38 39 public class SimpleRunnable implements Runnable { 40 public void run() { 41 System.out.println("In run method of for threads number : " + counter); 42 counter++; 43 } 44 } 45 } 46 | Popular Tags |