Почему у меня есть доступ к методу getName()
? Мой класс не расширяет класс Thread
только реализует интерфейс Runnable
.getName() из класса Thread
public class MyThread implements Runnable {
public void run() {
System.out.println("MyThread is running");
}
public static void main(String[] args){
MyThread thread1 = new MyThread();
Thread thr = new Thread(thread1, "thread");
thr.start();
System.out.println(thr.currentThread().getName());
System.out.println(thr.getName());//Why do I have access to this method?
}
}