File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed
Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -144,8 +144,8 @@ Thread类除了提供join()方法外,另外还提供了超时等待的方法
144144
145145可以看出来当前等待对象threadA会一直阻塞,直到被等待对象threadB结束后即isAlive()返回false的时候才会结束while循环,当threadB退出时会调用notifyAll()方法通知所有的等待线程。下面用一个具体的例子来说说join方法的使用:
146146
147- public class JoinDemo {
148- public static void main(String[ ] args) throws InterruptedException {
147+ public class JoinDemo {
148+ public static void main(String[] args) throws InterruptedException {
149149 for (int i = 0; i <= 10; i++) {
150150 MyThread thread = new MyThread();
151151 thread.start();
@@ -159,7 +159,7 @@ public class JoinDemo {
159159 }
160160 }
161161
162- static class MyThread extends Thread {
162+ static class MyThread extends Thread {
163163 @Override
164164 public void run() {
165165 try {
You can’t perform that action at this time.
0 commit comments