i want to terminate some process after some time if that process will not responded 
i used this code but i am not able to achive the same 

```
 long start = System.currentTimeMillis(); long end = start +60000;

 1 while (System.currentTimeMillis() < end)
 2                {                 
 3                   Connection.execute(function); // execute 
 4                   break; // break if response came                    
 5                }

 6 if(System.currentTimeMillis() > end)    
 7 { 
 8 close connection;  // close connection if line no 3 will not responded 
 9 }

```

kindly help me on the same