How to use batchUpdate() method

Please let me know how entity list should be pass inside for loop(
myListOfEntitiesToAdd
) as below:
provider.batchUpdate(new BatchUpdateCallback() {
public void batchUpdate(MutableEntityProvider batchEnabledEntityProvider) {
for (Entity e :
myListOfEntitiesToAdd
) {
batchEnabledEntityProvider.addEntity(e); }
}
});

Please provide full implemnetation…
Thanks