runImpl must return a boolean for this code to work. You probably want this to be in a new topic (basic tutorials abound) if you don't want your program to stall until it ends.
public Response run(Request req){
long lasttime=Sys.getTime();
int i=0;
while(i<10){
if(Response res = runImpl(req);){
return response;
}
if((Sys.getTime-lasttime)>1000){
i++;
lasttime=Sys.getTime();
}
}
return null;
This starts every processor moment, if you want it to work with an AS WELL interval for 10 seconds, use:
public Response run(Request req){
long lasttime=Sys.getTime();
int i=0;
for(int i; i<(10000/yourchoiceinterval); i++){
if(Response res = runImpl(req);){
return response;
}
if((Sys.getTime-lasttime)>1000){
lasttime=Sys.getTime();
}
}
return null;
source
share