@@ -0,0 +1,546 @@
+package extthread;%0A%0Apublic class ThreadB extends Thread %7B%0A%09Object lock;%0A%0A%09public ThreadB(Object lock) %7B%0A%09%09super();%0A%09%09this.lock = lock;%0A%09%7D%0A%0A%09@Override%0A%09public void run() %7B%0A%09%09synchronized (lock) %7B%0A%09%09%09for (int i = 0; i %3C 10; i++) %7B%0A%09%09%09%09MyList.add();%0A%09%09%09%09if (MyList.size() == 5) %7B%0A%09%09%09%09%09lock.notify();%0A%09%09%09%09%09System.out.println(%22%E5%B7%B2%E5%8F%91%E5%87%BA%E9%80%9A%E7%9F%A5%22);%0A%09%09%09%09%7D%0A%09%09%09%09System.out.println(%22%E6%B7%BB%E5%8A%A0%E4%BA%86%22 + (i + 1) + %22%E4%B8%AA%E5%85%83%E7%B4%A0%22);%0A%09%09%09%09try %7B%0A%09%09%09%09%09Thread.sleep(1000);%0A%09%09%09%09%7D catch (InterruptedException e) %7B%0A%09%09%09%09%09// TODO Auto-generated catch block%0A%09%09%09%09%09e.printStackTrace();%0A%09%09%09%09%7D%0A%09%09%09%7D%0A%09%09%7D%0A%09%7D%0A%7D%0A

Create ThreadB.java