此方式创建线程池
ExecutorService es = Executors.newCachedThreadPool();
希望能监控线程池的状况。
ExecutorService es = Executors.newCachedThreadPool();
希望能监控线程池的状况。
解决方案 »
- c语言的typedef unsigned short int16u; 这个咋在java表示?
- linux下Java获得文件的创建时间(精确到秒)
- 问一个不能结帖子的问题
- 怎样建一个交流平台????????????急急急急急!!!!!!
- eclipse event和layout 的翻译
- 指针问题,JAVA中的方式可以,C++中同样的方式为什么不行?
- swing的问题
- HttpURLConnection问题
- 初学者在线等待:关于tomcat的配置问题
- 简单的问题。怎么得到字体列表。
- httpclient 执行execute()方法所耗时间过长,怎么解决?
- 请问各位高手除了学JAVA还有学别的科目吗?
还是来顶顶
public static ExecutorService newCachedThreadPool() {
return new ThreadPoolExecutor(0, Integer.MAX_VALUE,
60L, TimeUnit.SECONDS,
new SynchronousQueue<Runnable>());
}
就是说,返回的是子类对象ThreadPoolExecutor的实例,
而ThreadPoolExecutor类提供了getPoolsize(),getActiveCount()等方法...
将你的es强制类型转换成ThreadPoolExecutor吧
这样可以了。谢谢
不过很悲剧的是 mina2中的ExecutorFilter线程池使用的是
OrderedThreadPoolExecutor继承ThreadPoolExecutor类
但是getQueue方法被禁止使用,源码如下
public BlockingQueue<Runnable> getQueue() {
throw new UnsupportedOperationException();
}