I have a class that makes a call to an AS/400 op system routine. Usually that routine will issue a return code indicating success or failure, but sometimes it hangs and returns nothing. My process is left waiting forever for the return code it will never get. So, I need some method to time out my call to this proc. The following is a psuedo-code example of the process.
class lookUp extends Thread{
public void run(){
boolean p = false;
String[] a = new String{someData elements...
for(int 1 = 0; i< a.length; i++){
p = new AS400Call(a); // how to time this out
// after a minute or so?
if (p) { do success processing }
else { do failure processing }
yield();
// apparently never getting to the yield if no
// response from AS400Call()and other threads
// suffer.
}
}
}
Any ideas would be appreciated.
class lookUp extends Thread{
public void run(){
boolean p = false;
String[] a = new String{someData elements...
for(int 1 = 0; i< a.length; i++){
p = new AS400Call(a); // how to time this out
// after a minute or so?
if (p) { do success processing }
else { do failure processing }
yield();
// apparently never getting to the yield if no
// response from AS400Call()and other threads
// suffer.
}
}
}
Any ideas would be appreciated.