Note: Perform y first and then waitPackage COM. common. test1; public class notify {private byte [] Lock = new byte [0]; public static void main (string ARGs []) {notify Mt = new notify (); Mt. demo ();} public void demo () {printthread A = new printthread ("A"); printthread B = new printthread ("B");. start (); B. start ();} class printthread extends thread {public printthread (string name) {This. setname (name);} public void run () {synchronized (LOCK) {int I; for (I = 0; I <100; I ++) {if (I % 10 = 0 & 0! = I) {try {lock. Y (); // wake up another process lock. wait (); // temporarily release resources} catch (interruptedexception e) {e. printstacktrace () ;}} system. out. println (this. getname () + ":" + I);} if (I = 100) {lock. running y (); // wake up another process system. out. println (this. getname () + ":" + I); this. stop ();}}}}}