总结

回顾总结线程的创建

1.继承Thread类
//main调用:
new MyThread1().start();


class MyThread extends Thread(){
    @Override
    public void run(){
        System.out.println("MyThread1");
    }
}
2.实现Runnable接口
//main调用:
new Thread(new MyThread2).start();


class MyThread2 implements Runnable{
    @Override
    public void run(){
        System.out.println("MyThread2");
    }
}
3.实现Callable接口
//main调用:
FutureTask<Integer> futureTask = new FutureTask<Integer>(new MyCallable);
new Thread(futureTask).start();
try{
    Integer integer = futureTask.get();
    System.out.println(integer);
}catch(InterruptedException e){
    e.printStackTrace();
}catch(ExecutionException e){
    e.printStackTrace();
}



class MyCallable implements Callable<Integer>{
    @Override
    public Integer call() throws Exception{
        System.out.println("MyThread3");
        return 100;
    }
}