i do not have to show these records on the front end to the user,if i had to show the records, then probably pagination is the best approach,as you have suggested.
I have implemented pagination in my earlier projects,which involved front end .
Instead i have to generate a report(essentially write to a file and provide the file to the user)..
Also i am using a single thread to retrieve data.Also at anytime only one thread will be active for this.
In the first class, instantiation of the singleton instance is done inside the getInstance() method. This method is not synchronized. Hence, two different threads may access it simultaneously. In such a scenario, it is possible that the null-check and instantiation are done by both the threads. This will result in two instances of the class (or for that matter, theoritically, n instances for n number of threads).