Executors.newFixedThreadPool 完成工作后继续方法

countinue a method after Executors.newFixedThreadPool finish's its job

我有一个方法。在这个方法中,我 运行 执行者的任务。它的工作是从服务器获取数据并填充结果 Arraylist。

   public Paginator(String secSrv, int total, ExecutorService executorService, Cookie cookie) {
    securitySrv = secSrv;
    totalItems = total;
    this.executorService = executorService;
    this.cookie = cookie;
}

ArrayList<Suser> results = new ArrayList<>();

public ArrayList<Suser> generatePage(int currentPage) {

    fetchAllUsers(currentPage);
    ......
    for (int i = startItem; i < startItem + numOfData; i++) {
            pageData.add(results.get(i-1));
        }

填充结果 Arraylist 后我必须使用这个 arraylist.how 我可以知道 executorService 在哪里完成它的工作并且我可以再次继续我的方法吗?

   private void fetchAllUsers(final int currentPage) {

    Runnable fetchUserListFromSrv = new Runnable() {
        @Override
        public void run() {
            android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_BACKGROUND);
            JSONObject count = new JSONObject();
            try {
                count.put("count", 10);
                count.put("page", currentPage);
                String SearchUsersPagingResult = ...
                results.addAll(susers) ;
            } catch (JSONException e) {
                e.printStackTrace();
            }

        }
    };

    executorService.submit(fetchUserListFromSrv);
}

使用文档。所有答案都在这里。

Future| Android developers

ExecutorService| Android developers