2020
10-10
10-10
Java多线程通信:交替打印ABAB实例
使用wait()和notify()实现Java多线程通信:两个线程交替打印A和B,如ABABABpublicclassTest{publicstaticvoidmain(String[]args){finalPrintABprint=newPrintAB();newThread(newRunnable(){publicvoidrun(){for(inti=0;i<5;i++){print.printA();}}}).start();newThread(newRunnable(){publicvoidrun(){for(inti=0;i<5;i+...
继续阅读 >