package com.yby7; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; class NumberThread implements Runnable{ @Override public void run() { for (int i = 0;i <= 100;i++){ if (i % 2 == 0){ System.out.println(Thread.currentThread().getName()+":"+i); } } } } public class Threadpool { public static void main(String[] args) { ExecutorService service = Executors.newFixedThreadPool(10); // service.submit();//适用于callable service.execute(new NumberThread());//适用于Rannable service.shutdown();//关闭线程 } }
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)