java线程间的通信
作者:
文艺小年青 | 来源:发表于
2017-09-21 20:42 被阅读0次package xianPack;
public class Test0 {
//线程间的通信
public static void main(String[] args) {
Runnable5 runnable5 = new Runnable5();
runnable5.age = 10;
Test0 test0 = new Test0();
runnable5.test0 = test0;
Thread thread = new Thread(runnable5);
thread.start();
}
void printAge(int age) {
System.out.println(age);
}
}
class Runnable5 implements Runnable {
int age;
Test0 test0;
@Override
public void run() {
System.out.println(this.age);
this.age++;
this.test0.printAge(this.age);
}
}
本文标题:java线程间的通信
本文链接:https://www.haomeiwen.com/subject/pdbtextx.html
网友评论