Added a mutex lock before creating the flows and initializing remainingFlows.