2

问一个 ExecutorService 的问题

 2 years ago
source link: https://www.v2ex.com/t/805237
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

V2EX  ›  Java

问一个 ExecutorService 的问题

  zhangLLL · 1 天前 · 390 次点击

想知道 ExecutorService 提交的任务先 sleep1 秒是何意义?

    ExecutorService executor = Executors.newSingleThreadExecutor();
    executor.submit(() -> {
        try {
            Thread.sleep(1000);

            doSomething();

        } catch (Exception e) {
            logger.error("异步接口执行失败", e);
        }
    });

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK