update: it looks like this is not a memory leak, will anyone create based on the extension of this example?
The original subject: Suppose I create and start a thread that does not interrupt, the thread creates an object and links as long as it is alive. See the following code. Does JVM collect garbage x? Will this be considered a memory leak?
public class MyRunnable implements Runnable{
public void run(){
X x = new X();
while(true){}
}
}
Thread t = new Thread(new MyRunnable());
t.start();
source
share