1.创建线程的方式?
实现Runnable,Callable接口,继承Thread类,使用Executor框架来创建线程池
1 | public class RunnableImpl implements Runnable{ |
1 | public class CallableImpl implements Callable<Integer> { |
1 | public class Mythread extends Thread{ |
1 | public class ThreadPoolExample { |
实现Runnable,Callable接口有哪些区别?
实现Callable接口能有返回值,而实现Runnable接口没有返回值