I have a List as per following:
private void someMethod () {
String str= "someStrParam";
private int theCount = 0;
List<String> itemList = getListMethod(str);
if (theCount < itemList.size()) {
return itemList.get(theCount++);
} else {
return null;
}
}
Question: As soon as a List item is added to the List in the getListMethod
, how can I access it immediately in the someMethod
without waiting for the next item to be added? Or is there way a way we put a monitor on getListMethod
so that, as soon as the an item is added there, we can query the itemList
?