packageveterinarian;importjava.io.DataOutputStream;importjava.io.IOException;importjava.util.Random;publicclassAnimalThreadextendsThread{privateWaitingRoomwr;privateStringanimal;privateRandomr;privateintid;publicAnimalThread(WaitingRoomwr,Stringanimal,Randomr,intid){this.wr=wr;this.animal=animal;this.r=r;this.id=id;}publicvoidrun(){System.out.println(animal+" "+id+" tries to enter");try{wr.EnterRoom(animal,id);}catch(InterruptedExceptione){e.printStackTrace();}intseconds=r.nextInt(10)+1;try{Thread.sleep(seconds*1000);}catch(InterruptedExceptione){e.printStackTrace();}wr.ExitRoom(animal,id);}}