ThreadLocalExecutor.submit(Callable)代码流程

125 阅读1分钟
    @Test
    public void test() throws ExecutionException, InterruptedException {
        Callable<String> callable = () -> "callable executed";
        ThreadPoolExecutor executor = new ThreadPoolExecutor(3, 10, 5, TimeUnit.SECONDS, new LinkedBlockingDeque<>());
        Future<String> submit = executor.submit(callable);
        System.out.println(submit.get());
    }
    // 执行结果
    callable executed

上述代码的执行大致过程 任务执行相关类图

类图