I think I may not be the first one with this problem. Sometimes, the user submits a bunch of data to the server, and these data is going to be displayed in the response page. In order to give users the illusion that the data submission and process is fast. We usually do this asynchronously. Now the problem is, for some reason, these data need to go to database first, and be fetched to appear in the response page. If the response page is displayed to the user too fast, asynchronous submission may not finish; Now I call
Thread.sleep();
before I call I setResponsePage().
but native thread is not recommended in EJB. Anyone knows alternatives ? Thanks