Added lock and unlock functions
updated the multi thread code