Assume a condition inside a Thread while true condition as shown below
package com;
import java.util.Date;
public class Tester extends Thread {
public void run() {
Date d = new Date();
while(true)
{
d = new Date();
}
}
}
will this code be a issue or not ??
Issue because : as it will create too many Date objects ??
Not an Issue because : as there no longer exists a reference to the old date object after the new assignment so therefor the garbage collector should cleanup the old object
I guess this will be not an issue , please suggest me if this code is fine .