Hi all,
I am doing two operations on a resource which I would explain step wise below:
Step 1: I am adding some content to a resource and then saving it.
Step 2: After this I am passing my resource to some other method as input. But this method needs updated saved resource from step 1. But execution happens so quickly that this method is not getting the updated resource.
The code looks like:
resource.getContents().add(model);
try {
resource.save(Collections.EMPTY_MAP);
} catch (IOException e) {
e.printStackTrace();
}
model.getMyObjs.addAll(readExcel(excelFile, resource).getEntriesList());
readExcel method is not getting the saved resource But if I add Thread.Sleep(milSec) then it works fine. Then code would look like:
resource.getContents().add(model);
try {
resource.save(Collections.EMPTY_MAP);
} catch (IOException e) {
e.printStackTrace();
}
try {
Thread.sleep(3000);
} catch (InterruptedException e1) {
e1.printStackTrace();
}
model.getMyObjs.addAll(readExcel(excelFile, resource).getEntriesList());
Its just a work around. How can I avoid this problem? How to wait until a resource is saved/loaded completely?
Please suggest some ideas.
Thanks in advance 