两个方法都可以向线程池提交任务,

execute()方法的返回类型是void,它定义在Executor接口中,

而submit()方法可以返回持有计算结果的Future对象,它定义在ExecutorService接口中,它扩展了Executor接口,其它线程池类像ThreadPoolExecutor和ScheduledThreadPoolExecutor都有这些方法。

相关文章:

  • 2023-02-01
  • 2021-08-17
  • 2022-12-23
  • 2021-09-23
  • 2021-06-28
  • 2021-07-01
  • 2021-08-11
猜你喜欢
  • 2021-08-13
  • 2021-09-15
  • 2022-12-23
  • 2022-12-23
  • 2021-06-29
  • 2022-12-23
相关资源
相似解决方案