prevent different threads reading and writing to the same object