mutex lock for javascript