Package java.util.concurrent

Examples of java.util.concurrent.ForkJoinPool.shutdown()


    task.join();
   
    /*
     * Shutdown the pool
     */
    pool.shutdown();
   
    /*
     * Wait for the finalization of the pool
     */
    pool.awaitTermination(1, TimeUnit.DAYS);
View Full Code Here


        Map<Long, Integer> matches = new HashMap<>();
        ForkJoinPool pool = new ForkJoinPool();
        pool.invoke(new PatternMatcher(regex, input, matches, db, graphManager));

        // Cleaning up after yourself is important
        pool.shutdown();
        try {
            pool.awaitTermination(5, TimeUnit.SECONDS);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
View Full Code Here

        e.printStackTrace();
      }
    } while ((!system.isDone())||(!apps.isDone())||(!documents.isDone()));
   
    // Shutdown the pool
    pool.shutdown();
   
    // Write the number of results calculate by each task
    List<String> results;
   
    results=system.join();
View Full Code Here

            }

        } while (!task.isDone());

        // Shutdown the pool
        pool.shutdown();

        // Wait for the finalization of the tasks
        try {
            pool.awaitTermination(1, TimeUnit.DAYS);
        } catch (InterruptedException e) {
View Full Code Here

        e.printStackTrace();
      }
    } while (!task.isDone());
 
    // Shutdown the pool
    pool.shutdown();
   
    // Check if the task has completed normally
    if (task.isCompletedNormally()){
      System.out.printf("PeriodictskExecution: The process has completed normally.\n");
    }
View Full Code Here

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

}
View Full Code Here

    //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();
  }
 
  public List<String> tbData(List<Map<String,String>> detailLinks) throws InterruptedException, ExecutionException{
    ForkJoinPool forkJoinPool = new ForkJoinPool(5);
View Full Code Here

  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();
  }
 
  private int dataLinkPages(String issueNo,int is_not_full,String userName,boolean onsale){
    int linkPages = 0;
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();
  }

  public List<String> readData(Integer pageNo) {
    String url = "http://www.infoq.com/cn/articles/"+12*(pageNo-1);
    List<String> resList = new ArrayList<String>();
View Full Code Here

        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

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.