Package wwww

Source Code of wwww.CalculatorTest

package wwww;

import java.util.List;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.Future;

import org.junit.Test;

public class CalculatorTest {

  public static long max = 10000l;
  @Test
    public void run() throws Exception{
    long b = System.currentTimeMillis();
    long sum = 0;
        for (int i = 1; i < max; i++) {
      sum += i;
    }
        System.out.println(sum);
        System.out.println(System.currentTimeMillis()-b);
        //assertEquals(new Integer(49995000), result.get());
    }
  @Test
    public void testA() throws Exception{
    long b = System.currentTimeMillis();
        ForkJoinPool forkJoinPool = new ForkJoinPool();
        Future<Integer> result = forkJoinPool.submit(new Calculator(0, max));
        System.out.println("testA:"+result.get());
        System.out.println("testA:"+(System.currentTimeMillis()-b));
        //assertEquals(new Integer(49995000), result.get());
    }
 
  @Test
    public void testForkJoinFirst() throws Exception{
    long b = System.currentTimeMillis();
    ForkJoinPool forkJoinPool = new ForkJoinPool();
        //Future<List<String>> result = forkJoinPool.submit(new ForkJoinFirst(0,150));
        //System.out.println("testForkJoinFirst>>>size:"+result.get().size()+"time:"+(System.currentTimeMillis()-b));
        //assertEquals(new Integer(49995000), result.get());
    }
 
  @Test
    public void testNormal() throws Exception{
    long b = System.currentTimeMillis();
   
        System.out.println("顺序执行>>>size:time:"+(System.currentTimeMillis()-b));
        //assertEquals(new Integer(49995000), result.get());
    }
 
}
TOP

Related Classes of wwww.CalculatorTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.