The difference between Executors.newSingleThreadExecutor().execute(command) and new Thread(command).start();

后端 未结 6 548
醉酒成梦
醉酒成梦 2020-12-23 16:57

Well title says it, what is the difference between Executors.newSingleThreadExecutor().execute(command) and new Thread(command).start();

6条回答
  •  时光说笑
    2020-12-23 17:34

    Behaviourally, pretty much nothing.

    However, once you have an Executor instance, you can submit multiple tasks to it, and have them executed one after another. You can't do that simply with a raw Thread.

提交回复
热议问题