Bug fix

Fixed bug that make multiple threads executing at the same time on the
cirtical flow

Signed-off-by: Mohamad Gebai <mohamad.gebai@polymtl.ca>