class PingPong2 {
synchronized void hit(long n) {
for(int i = 1; i < 3; i++)
System.
out.
print(n
+ "-" + i
+ " "); }
}
static PingPong2 pp2 = new PingPong2();
public static void main
(String[] args
) { new Thread(new Tester
()).
start(); new Thread(new Tester
()).
start(); }
public void run
() { pp2.
hit(Thread.
currentThread().
getId()); } }
Y2xhc3MgUGluZ1BvbmcyIHsKICAgIHN5bmNocm9uaXplZCB2b2lkIGhpdChsb25nIG4pIHsKICAgICAgICBmb3IoaW50IGkgPSAxOyBpIDwgMzsgaSsrKQogICAgICAgICAgICBTeXN0ZW0ub3V0LnByaW50KG4gKyAiLSIgKyBpICsgIiAiKTsKICAgIH0KfQoKY2xhc3MgVGVzdGVyIGltcGxlbWVudHMgUnVubmFibGUgewogICAgc3RhdGljIFBpbmdQb25nMiBwcDIgPSBuZXcgUGluZ1BvbmcyKCk7CiAgICBwdWJsaWMgc3RhdGljIHZvaWQgbWFpbihTdHJpbmdbXSBhcmdzKSB7CiAgICAgICAgbmV3IFRocmVhZChuZXcgVGVzdGVyKCkpLnN0YXJ0KCk7CiAgICAgICAgbmV3IFRocmVhZChuZXcgVGVzdGVyKCkpLnN0YXJ0KCk7CiAgICB9CiAgICBwdWJsaWMgdm9pZCBydW4oKSB7IHBwMi5oaXQoVGhyZWFkLmN1cnJlbnRUaHJlYWQoKS5nZXRJZCgpKTsgfQp9