public class testPool { public static void main(String[] args) { //创建服务,设置线程池大小大小 ExecutorService service = Executors.newFixedThreadPool(10); //执行线程 service.execute(new Pool()); service.execute(new Pool()); service.execute(new Pool()); service.execute(new Pool()); //关闭连接 service.shutdown(); } } class Pool implements Runnable{ @Override public void run() { System.out.println(Thread.currentThread().getName()); } }
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)