/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package mt; import java.util.logging.Level; import java.util.logging.Logger; /** * * @author (C)Y.D.Zakovryashin, 09.01.2023 */ public class Ball { public synchronized void hit(String name, int delay) { System.out.print(name + " -> "); try { notify(); wait(); Thread.currentThread().sleep(delay); } catch (InterruptedException ex) { System.out.println("Exception: " + ex.getMessage()); } } }