package veterinarian; import java.io.DataOutputStream; import java.io.IOException; import java.util.Random; public class AnimalThread extends Thread { private WaitingRoom wr; private String animal; private Random r; private int id; public AnimalThread(WaitingRoom wr, String animal, Random r, int id) { this.wr = wr; this.animal = animal; this.r = r; this.id = id; } public void run() { System.out.println(animal + " " + id + " tries to enter"); try { wr.EnterRoom(animal, id); } catch (InterruptedException e) { e.printStackTrace(); } int seconds = r.nextInt(10) + 1; try { Thread.sleep(seconds * 1000); } catch (InterruptedException e) { e.printStackTrace(); } wr.ExitRoom(animal, id); } }