总结

package com.hua.demo3;

import java.util.concurrent.*;

public class ThreadNew {
    public static void main(String[] args) {
        new MyThread1().start();
        new Thread(new MyThread2()).start();

        FutureTask<Integer> futureTask = new FutureTask<Integer>(new MyThread3());
        new Thread(futureTask).start();

        try {
            Integer integer = futureTask.get();
            System.out.println(integer);
        } catch (InterruptedException e) {
            e.printStackTrace();
        } catch (ExecutionException e) {
            e.printStackTrace();
        }

    }
}
class MyThread1 extends Thread{
    @Override
    public void run() {
        System.out.println("MyThread1");
    }
}
class MyThread2 implements Runnable{
    @Override
    public void run() {
        System.out.println("MyThread2");
    }
}
class MyThread3 implements Callable{

    @Override
    public Object call() throws Exception {
        System.out.println("MyThread3");
        return 100;
    }
}

 

上一篇:常见dos命令


下一篇:Android 开发学习进程0.32 dwonloadmanager使用