java - Adding a delay based on size of an array -
i need introduce wait in application based on size of array. if size of array 100 wait time 5000
each next batch of 1000 delay time incremented 1 second each . best possible way ? sample code
int waittime = 5000; if(array.length < 100) { waittime= 5000; } if(array.length > 100 && array.length <=1000) { waittime = waittime+ 1000; }
i find no problem code. if can create relation between array size , sleep time can write in 1 line .. following
thread.sleep(array.length < 100 ? 5000 : 6000 + 1000 * (array.length / 1000));
Comments
Post a Comment