/**
*分段计算1~100的和
* * 要求分为:0~25,25~50,50~75,75~100同时计算
*/
package com.qf.demo01;
//导的包
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
public class Demo09 {
public static void main(String[] args) {
/**
* 分段计算1~100的和
* 要求分为:0~25,25~50,50~75,75~100同时计算
*/
//建立的对象进行分段计算
ExecutorService es = Executors.newCachedThreadPool();
SumCallable callable01 = new SumCallable(0, 25);
SumCallable callable02 = new SumCallable(25, 50);
SumCallable callable03 = new SumCallable(50, 75);
SumCallable callable04 = new SumCallable(75, 101);
//传入分段对象进行启动线程
Future<Integer> future01 = es.submit(callable01);
Future<Integer> future02 = es.submit(callable02);
Future<Integer> future03 = es.submit(