Stop and Continue Looping of For Loop In Java -
i have project in having "for loop" iterating on arraylist. need stop iteration in between , continue again. tried doing applying "if else" condition in between didn't work.
i have arraylist of size 2500 , need loop iterate 500 times , wait , call function , again continue looping , stop after next 500 , on.
here have tried far:
int msgcount = 0; arraylist<jsoninput > savearraylist = new arraylist<jsoninput >(); for(jsoninput jsoninput: arrxmlstring){ publisher.send(jsoninput); savearraylist.add(jsoninput); if(msgcount<500){ // loop 500 times , increment msgcount msgcount++; } else { msgcount=0; sentservice.sendarraylist(savearraylist); savearraylist.clear(); } }
this not working. loop not stop , when debug stops in "else" condition loop not wait condition complete.
i have arraylist of size 2500 , need loop iterate 500 times , wait , call function , again continue looping , stop after 500 , on
create temporary list add each item into. use loop , check index value of loop - if value divisible 500 call necessary code.
//presuming arrxmlstring list list<jsoninput> savearraylist = new arraylist<jsoninput>(); ( int = 0; < arrxmlstring.size(); i++ ){ jsoninput jsoninput = arrxmlstring.get(i); publisher.send(jsoninput); savearraylist .add(jsoninput); if ( % 500 == 0 && > 0 ){ sentservice.sendarraylist(templist); savearraylist .clear(); } }
Comments
Post a Comment