join()的用法下面的程序是不是就是t1、t2都运行结束,主线程才会继续往下继续执行。
Java里没有ANR问题吧
public static void main(String[] args) {
MyArray ma = MyArray.getInstance();
Thread t1 = new Thread(new SetValue(ma,8));
Thread t2 = new Thread(new SetValue(ma,8));
t1.start();
t2.start();
try {
t1.join();
} catch (InterruptedException e) {
e.printStackTrace();
}
try {
t2.join();
} catch (InterruptedException e) {
e.printStackTrace();
}
ma.print();
}
|
|