Need a solution to avoid multiple lock from the same thread