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

Popular posts from this blog

iphone - Three second countdown in cocos2d -

hyperlink - how to do url routing in php -

c++ - CryptStringToBinary API behavior -