线程池的问题。如何监控线程池中线程,比如查看正在等待中的任务个数 .................................... 此方式创建线程池ExecutorService es = Executors.newCachedThreadPool();希望能监控线程池的状况。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 多看看API看有没有有用的方法,我是没找到对这个类不熟悉,没用过还是来顶顶 Executors.newCachedThreadPool()的源代码是 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();} java读取文本文件最后一行 java.util.TreeSet 可以放入重复的元素? 求一pl/sql简单教程 jsp相关问题!!!!等!!急 接口问题 匪夷所思的一道考题,求教高手!在线等 Redhat 9下 jdk1.4.2安装成功,为什么javac不能用?? 点击button在Tree里添加一个节点,怎么做? JDK1.3 下命令行“java -cp ... ”超过256个字符怎么办? 轻量型Java服务器关于响应的问题 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();
}