I am working for multithreaded application, so i have a thread which has one Global ArrayList variable, I am fetching list of values from database and assigning it to that variable. I have restricted how many list should fetch, to 100. In backend i am using hibernate.
I have kept this thread running in background periodically, But what i wanted to do that, whenever this thread runs, it will fetch next 100 list of items. And also i don't want to use static and don't want to maintain it in a database, i am confuse how to maintain a counter that will tell my fetching method that next 100 item to fetch. can anybody help, how can i achieve this? Following is my code sample,
public class DemoThread implements Runnable {
private ArrayList <<>> samplePojoList = null;
@Override
public void run() {
MyDaoClass dao = null;
try {
// this dao method fetching list of 100 results from database,
// for each iteration i want to fetch next 100 result from
// database
samplePojoList = dao.getSampleList();
} catch (Exception e) {}
}
}