Package java.util.concurrent

Examples of java.util.concurrent.ForkJoinPool$ManagedBlocker


       restlets.add(routable);
    }
   
    public RestApiServer(ControllerRef cRef) {
       this.restlets = new ArrayList<org.flowforwarding.warp.jcontroller.restapi.RestletRoutable>();
       this.pool = new ForkJoinPool();
       org.flowforwarding.warp.jcontroller.restapi.RestletRoutable routable = new org.flowforwarding.warp.jcontroller.restapi.RootRestApiRoutable(cRef, this.pool);
       restlets.add(routable);
    }
View Full Code Here


    ga2.evolve(termination.<Double>SteadyFitness(10));
  }

  @Test(invocationCount = 10)
  public void evolveForkJoinPool() {
    final ForkJoinPool pool = new ForkJoinPool(10);

    try {
      final Factory<Genotype<DoubleGene>> factory = Genotype.of(DoubleChromosome.of(-1, 1));
      final Function<Genotype<DoubleGene>, Double> ff = new FF();

      final GeneticAlgorithm<DoubleGene, Double> ga = new GeneticAlgorithm<>(
        factory, ff, pool
      );
      ga.setPopulationSize(1000);
      ga.setAlterer(new MeanAlterer<DoubleGene>());
      ga.setOffspringFraction(0.3);
      ga.setOffspringSelector(new RouletteWheelSelector<DoubleGene, Double>());
      ga.setSurvivorSelector(new StochasticUniversalSelector<DoubleGene, Double>());

      ga.setup();
      for (int i = 0; i < 10; ++i) {
        ga.evolve();
      }
    } finally {
      pool.shutdown();
    }
  }
View Full Code Here

    return linkList;
  }
 
  public List<Map<String,String>> tbDataLinks(String issueNo,int is_not_full,String userName,boolean onsale) throws InterruptedException, ExecutionException{
    //ForkJoinPool forkJoinPool = new ForkJoinPool(Runtime.getRuntime().availableProcessors());
    ForkJoinPool forkJoinPool = new ForkJoinPool(5);
    int detailLinkPages = dataLinkPages(issueNo, is_not_full, userName, onsale);
    TBDataLinkThread thread = new TBDataLinkThread(1,detailLinkPages,issueNo, is_not_full,userName,onsale,this);
        Future<List<Map<String,String>>> result = forkJoinPool.submit(thread);
        forkJoinPool.shutdown();
    return result.get();
  }
View Full Code Here

        forkJoinPool.shutdown();
    return result.get();
  }
 
  public List<String> tbData(List<Map<String,String>> detailLinks) throws InterruptedException, ExecutionException{
    ForkJoinPool forkJoinPool = new ForkJoinPool(5);
    int size = detailLinks.size();
    TBDataThread thread = new TBDataThread(0,size-1,detailLinks,this);
        Future<List<String>> result = forkJoinPool.submit(thread);
        forkJoinPool.shutdown();
    return result.get();
  }
View Full Code Here

            }
        });
    }
 
  public void readDataLink() throws InterruptedException, ExecutionException{
    ForkJoinPool forkJoinPool = new ForkJoinPool(10);
        ForkJoinFirst firstTask = new ForkJoinFirst(1,150,this);
        Future<List<String>> result = forkJoinPool.submit(firstTask);
        System.out.println(result.get().size());
        forkJoinPool.shutdown();
  }
View Full Code Here

        //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());
    }
View Full Code Here

    }
 
  @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());
    }
View Full Code Here

  private String path;
  private String extension;

  public static void main(String[] args) {
    ForkJoinPool pool = new ForkJoinPool(12);
    // 创建3个FolderProcessor任务。用不同的文件夹路径初始化每个任务。

    FolderProcessor system = new FolderProcessor("C:\\", "txt");
    FolderProcessor apps = new FolderProcessor("D:\\", "txt");
    FolderProcessor documents = new FolderProcessor("E:\\", "txt");
    // 在池中使用execute()方法执行这3个任务。
    pool.execute(system);
    pool.execute(apps);
    pool.execute(documents);
    // 将关于池每秒的状态信息写入到控制台,直到这3个任务完成它们的执行。
    do {
      System.out.printf("******************************************\n");
      System.out.printf("Main: Parallelism: %d\n", pool.getParallelism());
      System.out.printf("Main: Active Threads: %d\n", pool.getActiveThreadCount());
      System.out.printf("Main: Task Count: %d\n", pool.getQueuedTaskCount());
      System.out.printf("Main: Steal Count: %d\n", pool.getStealCount());
      System.out.printf("******************************************\n");
      try {
        TimeUnit.SECONDS.sleep(1);
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
    } while ((!system.isDone()) || (!apps.isDone())
        || (!documents.isDone()));
    // 使用shutdown()方法关闭ForkJoinPool。
    pool.shutdown();
    // 将每个任务产生的结果数量写入到控制台。

    List<String> results;
    results = system.join();
    System.out.printf("System: %d files found.\n", results.size());
View Full Code Here

    return totalPage;
  }
 
  public List<String> wyDataLinks(String issueNo,int is_not_full) throws InterruptedException, ExecutionException{
    //ForkJoinPool forkJoinPool = new ForkJoinPool(Runtime.getRuntime().availableProcessors());
    ForkJoinPool forkJoinPool = new ForkJoinPool(5);
    int linkPages = dataLinkPages(issueNo, is_not_full);
    DataLinkThread thread = new DataLinkThread(1,linkPages,issueNo, is_not_full,this);
        Future<List<String>> result = forkJoinPool.submit(thread);
        forkJoinPool.shutdown();
    return result.get();
  }
View Full Code Here

        forkJoinPool.shutdown();
    return result.get();
  }
 
  public List<String> wyDatas(List<String> lottOrderIds) throws InterruptedException, ExecutionException{
    ForkJoinPool forkJoinPool = new ForkJoinPool(5);
    int size = lottOrderIds.size();
    DataThread thread = new DataThread(0,size-1,lottOrderIds,this);
        Future<List<String>> result = forkJoinPool.submit(thread);
        forkJoinPool.shutdown();
    return result.get();
  }
View Full Code Here

TOP

Related Classes of java.util.concurrent.ForkJoinPool$ManagedBlocker

Copyright © 2018 www.massapicom. 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.