Fixed unlock and barrier_wait order