public static void main(String[] args) throws InterruptedException {
        ExecutorService service = Executors.newFixedThreadPool(4);
        List<WordLengthCallable> listThreads = new ArrayList<WordLengthCallable>(
                Arrays.asList(
                        new WordLengthCallable(), new WordLengthCallable(),
                        new WordLengthCallable(), new WordLengthCallable())
        );
        CompletionService<Integer> completionService = new ExecutorCompletionService(service);
        for (WordLengthCallable elem: listThreads) {
            if (elem instanceof Callable) {
                completionService.submit(elem);
            }
        }
        for (int i = 0; i < 4; i++) {
            try {
                int result = completionService.take().get().intValue();
                System.out.println("result is " + result);
            } catch (ExecutionException e) {
                e.printStackTrace();
            }
        }
        service.shutdown();
    }