Amazon EC2 PublicDnsName
===

How to get PublicDnsName in amazonEC2?
we can get it from instance using ins.getPublicDnsName() but it get created after a certain time,is there any alternative way to get it?
Or some how get it as soon as it is generated?
for making it wait i did 
`while(flag) {
	    	  time = System.currentTimeMillis() - start;
	    	  for (Reservation res : ec2.describeInstances().getReservations()) {
	 	    	 for (Instance ins : res.getInstances()) {
	 	    		 if(ins.getState().getName().equalsIgnoreCase("running") || time == MAX_TIME_FOR_THREAD){	 	    			 
	 	    			 System.out.println(ins.getPublicDnsName()+"#########"+ins.getInstanceId());
	 	    			 flag = false;
	 	    			 break;
	 	    		 }
	 	    	 }
	 	    		
	 			}	    	  	    	 
	      }`

but inside a run of thread but while I am creating multiple ec2 resources it is returning dns of first up machine multiple times where as i feel it should return different dns address.