1 21 package org.jsmtpd.generic.threadpool; 22 23 27 public class ThreadPoolTest { 28 29 public static void main(String [] args) throws InterruptedException { 30 ThreadPool pool = null; 31 try { 32 pool = new GenericThreadPool(20, "org.jsmtpd.generic.threadpool.DummyThread","Dummy"); 33 } catch (InstantiationException e) { 34 e.printStackTrace(); 35 } catch (IllegalAccessException e) { 36 e.printStackTrace(); 37 } catch (ClassNotFoundException e) { 38 39 e.printStackTrace(); 40 } 41 42 int cp=0; 51 while (cp<100) { 52 for (int i=0;i<20;i++) { 53 try { 54 pool.assignFreeThread("Test !"); 55 } catch (BusyThreadPoolException e) { 56 } 57 } 58 Thread.sleep(3000); 59 cp++; 60 } 61 Thread.sleep(30000); 62 72 80 pool.forceShutdown(); 81 System.err.println("pool down"); 82 91 System.out.println("main Go sleep"); 92 try { 93 Thread.sleep(10000); 94 } catch (InterruptedException e1) { 95 e1.printStackTrace(); 96 } 97 System.out.println("main wake"); 98 pool.forceShutdown(); 99 System.out.println("pool clean"); 100 101 } 102 } | Popular Tags |