Java Reference
In-Depth Information
System.out.println("Before response : "+new
Date());
Future<String> response =
target.request(MediaType.APPLICATION_JSON).async().get(String.class);
new PassiveWaiting(response).start();
System.out.println("After PassiveWaiting :
"+new Date());
}
static class PassiveWaiting extends Thread {
Future<String> response;
public PassiveWaiting(Future<String>
response){
this.response = response;
}
public void run(){
try{
System.out.println("response
:"+response.get()+", time : "+new Date());
}catch(Exception ex){
ex.printStackTrace();
}
}
}
}
To ensure that the processing is executed asynchronously, we have defined a break
of 20 seconds in the getListOfAllStudentsAs method before executing the
JPQL queries. The following code,which is a simulation of a slow processing, shows
the contents of the method executed by the client:
@GET
@Path("getListOfAllStudentsAs")
Search WWH ::




Custom Search