execute和submit的主要区别是什么?

2026-04-30 05:051阅读0评论SEO基础
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计840个文字,预计阅读时间需要4分钟。

execute和submit的主要区别是什么?

1. `execute` 方法在 `java.util.concurrent.Executor` 中的定义:`void execute(Runnable command);`

2.`execute` 方法的具体实现:`public void execute(Runnable command) { if (command==null) throw new NullPointerException(); /* ... */ }`

3.实现步骤:抛出 `NullPointerException`,如果 `command` 为 `null`。

阅读全文

本文共计840个文字,预计阅读时间需要4分钟。

execute和submit的主要区别是什么?

1. `execute` 方法在 `java.util.concurrent.Executor` 中的定义:`void execute(Runnable command);`

2.`execute` 方法的具体实现:`public void execute(Runnable command) { if (command==null) throw new NullPointerException(); /* ... */ }`

3.实现步骤:抛出 `NullPointerException`,如果 `command` 为 `null`。

阅读全文