标签:
看下两段代码就明白了:
1、ThreadPoolExecutor
final ThreadPoolExecutor tpe = new ThreadPoolExecutor(5,10,0L, TimeUnit.MILLISECONDS,new LinkedBlockingQueue<Runnable>()); public void resolve(Serializable objectMessage) throws Exception { final MessageBean bean = (MessageBean)objectMessage; //多线程消息发送 tpe.submit(new Runnable() { public void run() { MessageServiceImpl.service.defaultNotice(bean); } }); }
public static ExecutorService newFixedThreadPool(int nThreads) { return new ThreadPoolExecutor(nThreads, nThreads, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>()); }
a、newFixedThreadPool是一个生产ThreadPoolExecutor对象的工厂。
b、newFixedThreadPool创建的是固定大小线程池的工厂。
ThreadPoolExecutor与newFixedThreadPool
标签:
原文地址:http://my.oschina.net/weiweiblog/blog/492378