How does `wait()` behave in a multithreaded environment with shared resources?
`wait()` allows the thread to pause execution while another thread performs some action on the shared resource.
Thatâ€™s partially correct. While `wait()` pauses the thread, the main point is that it waits for a signal before resuming.
Can you explain how `wait()` and `notify()` together help manage access to shared resources in a synchronized environment?