[Java] import java. util. arrayList; import java. util. list; class Plate {private List <Object> apples = new ArrayList <Object> (); public synchronized void putApple (Object apple) {if (apples. size ()> 0) {try {wait ();} catch (InterruptedException e) {e. printStackTrace () ;}} apples. add (apple); y (); System. out. println ("put an apple");} public synchronized void getApple () {if (apples. size () = 0) {try {wait ();} catch (InterruptedException e) {e. printStackTrace () ;}} Object apple = apples. get (0); apples. clear (); Using Y (); System. out. println ("get an apple") ;}} class Add implements Runnable {private Plate applePlate; private Object apple = new Object (); public Add (Plate applePlate) {this. applePlate = applePlate ;}@ Override public void run () {for (int I = 0; I <5; I ++) {applePlate. putApple (apple) ;}} class Get implements Runnable {private Plate applePlate; public Get (Plate applePlate) {this. applePlate = applePlate ;}@ Override public void run () {for (int I = 0; I <5; I ++) {applePlate. getApple () ;}} public class SynchroTest {public static void main (String args []) {Plate myPlate = new Plate (); new Thread (new Get (myPlate )). start (); new Thread (new Add (myPlate )). start ();}}