通过线程池创建线程
public class ThreadDemo03 {
2 public static void main(String[] args) {
3 Callable<Object> oneCallable = new Tickets<Object>();
4 FutureTask<Object> oneTask = new FutureTask<Object>(oneCallable);
5 Thread t = new Thread(oneTask);
6 System.out.println(Thread.currentThread().getName());
7 t.start();
8 }
9 }
10
11 class Tickets<Object> implements Callable<Object>{
12 //重写call⽅法
13 @Override
14 public Object call() throws Exception {
15 // TODO Auto-generated method stub
16 System.out.println(Thread.currentThread().getName()+"-->我是通过实现Callable接⼝通过FutureTask包装器来实现的线程"
17 return null;
18 }
19 }