if 'parent' is the last non-daemon thread running (and thus 'child1' and child2' threads are daemon threads), then when 'parent' dies, the JVM starts to shutdown, so the 'child' threads would also die.
---> I have a similar kind of situation, like I am starting a thread from a method. Method will return a value to caller and thread should to rest of the process.
But what happens is thread is starting the process, it stops in between without throwing any exception or error.
example :
public class ThreadTest{
public
String testAbc(){
String s ="Hello";
(new Thread(new MyThread())).start();
return s;
}
public class MyThread implements Runnable {
public void run() {
// Process rest ...
}
}
}
Can anybody tell me why it is happening?
What is the solution for this?
Thanks,
Rakesh