有一个最大并发量为10的线程池;往该线程池中同时提交100个计算任务,计算任务分为四种类型分别为两数之和、两数之差、两数乘积及两数除法,每种类型分别有25个任务。请编写一个程序实现上述逻辑,并描述实现思路。
public class Demo {
private static double z;
public static void main(String[] args) {
ExecutorService service = Executors.newFixedThreadPool(10);
for (int i = 0; i < 25; i++) {
service.execute(new Runnable() {
@Override
public void run() {
System.out.println(Thread.currentThread().getName()+" 结果为:"+add(12, 12));
}
});
service.execute(new Runnable() {
@Override
public void run() {
System.out.println(Thread.currentThread().getName()+" 结果为:"+difference(31, 12));
}
});
service.execute(new Runnable() {
@Override
public void run(