Race condition when waiting for all processing to complete