You can place that for loop in a separate function which is called by thread(): 
Processing.org/reference/thread_.html
You can update a global variable w/ the current index the for loop is currently processing. 
And then, the draw() function can use that global variable to determine how big to draw the progress bar. 