I have a list of 15,000 records. I can maintain the count in a flag.
Integer Counter = 15000;
I want to break my main list into 3 small lists. Each list should contain 5,000 records. First list should contain first 5000 records and second list should contain the next 5,000 records and so on.
The reason behind this: I want to pass each list of 5000 records to a queueable job or create three queueable jobs.
if(mainLst.size() > counter)
{
List<Custom__C> newList = new List<Custom__C>();
List<Custom__C> newList1 = new List<Custom__C>();
List<Custom__C> newList2 = new List<Custom__C>();
for(Integer i = 0; i< counter; i++)
{
newList1.add(mainLst[i]);
}
// Perform some operation with newList1
// Perform some operation with newList2
// Perform some operation with newList3
}