/** * Competes with another Player object for the PingPong monitor. */ public class Player implements Runnable { PingPong myTable; // Table where they play String myOpponent; /** * new player with the designated opponent and table. */ public Player(String opponent, PingPong table) { myTable = table; myOpponent = opponent; } /** * Start running. Basically repeatedly call hit on the * table. */ public void run() { String x = Thread.currentThread().getName(); System.out.println(x+" is Running."); while (myTable.hit(myOpponent)) ; System.out.println(x+" is Exiting."); } }