/
Nicholas
/
java_basics
Обзор
Документация
Войти
/
Nicholas
/
java_basics
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
Multithreading/Deadlock/src/Friend.java
22 строки
523 B
Skillbox
Add lesson
12 ноя 2023, 22:22
12 ноя 2023, 22:22
39eebf6
Код
Авторство
О чём код?
public class Friend implements Comparable<Friend> { private final String name; public Friend(String name) { this.name = name; } public String getName() { return this.name; } public synchronized void throwBallTo(Friend catcher) { System.out.format("%s: %s кинул мне мяч!%n", catcher.getName(), this.name); catcher.throwBallTo(this); } @Override public int compareTo(Friend o) { return this.getName().compareTo(o.getName()); } }