¿Cómo encontrar el nombre del hilo padre?
Sé que podemos tener 'padres' e 'hijos' cuando hablamos de procesos. Pero ¿es posible conseguir padres?Thread
¿nombre?
Hice mi investigación, pero he encontrado respuesta sólo para.Red
Edición: he intentado establecer nombres:
public class Main {
public static void main(String[] args) {
Thread r = new ThreadA();
r.start();
}
}
public class ThreadA extends Thread {
public void run() {
Thread.currentThread().setName("Thread A");
System.out.println("Here " + Thread.currentThread().getName());
Thread r = new ThreadB();
r.setName(Thread.currentThread().getName());
r.start();
}
}
public class ThreadB extends Thread {
public void run() {
Thread.currentThread().setName("Thread B");
System.out.println("Here " + Thread.currentThread().getName());
Thread r = new ThreadC();
r.setName(Thread.currentThread().getName());
r.start();
}
}
public class ThreadC extends Thread {
public void run() {
Thread.currentThread().setName("Thread C");
System.out.println("Here " + Thread.currentThread().getName());
}
}