实现多线程的四种方式

1、继承Thread类,重写run方法

2、实现Runnable接口,实现改接口的run方法

3、实现callable接口,重写call方法

4、通过线程池创建线程

前面两种可以归结为一类:无返回值,原因很简单,通过重写run方法,run方式的返回值是void,所以没办法返回结果

后两种归为一类:有返回值,通过callable接口,实现call方法,这个返回值是Object,所以返回结果放在Object对象中

https://blog.csdn.net/u011480603/article/details/75332435

原文地址:https://www.cnblogs.com/9797ch/p/11539679.html