小编nik*_*983的帖子

线程如何在完成工作后返回值?

假设我们有这个简单的例子:

public Example extends Thread{

    String temp;    

    public Example(){
    }

    @Override
    public void run(){
        .
        .
        .
        .
        temp = "a_value";
    }

    public static void main(String[] args) {

        Example th = new Example();
        th.start();
    }

}
Run Code Online (Sandbox Code Playgroud)

Thread完成工作后怎么能给我返回String temp?

java multithreading

45
推荐指数
3
解决办法
7万
查看次数

标签 统计

java ×1

multithreading ×1