first: sorry for the nooby question!
consider a normal basic Java programm:
public class TestClass {
public static void main(String[] args) {
Thread t=new Thread()
{
public boolean isRunning;
public void run()
{
while(isRunning);
}
}
t.isRunning=true;
t.start();
t=null;
}
}
The Thread would run for ever doesnt he?
How would I stop the Thread when I accidently set it to null like in the code above? Or what happens if for some reason the Thread object gets nullified?
Basically how does the programm behave? Can I query somehow a running thread without any reference to it and the i just yould stop() it somehow?
Now what about when the Thread object also holds some Data that is needed and will be used in the run method? Are they null or can they still be accessed?
If so it is really essential to get the reference of the object back again even more
edit: I added an android tag to the question. I am more thinking of Android enviroments. The process of an app can be killed very easy and things can go so wrong that a thread gets nullified but its execution is still going on, so getting the reference of a thread back again is important. Like when an activity is killed by the system its reference to a thread is also gone. So before a memory leak occurs there must be sth i can do to prevent from having an ongoing thread before starting another one