Use lock to make all operations wait if needed before execute