What is the `notifyAll()` method in Java used for?
`notifyAll()` wakes up all threads that are waiting on the object's monitor, allowing them to attempt to acquire the lock.
Great! Youâ€™re right. `notifyAll()` ensures that all waiting threads are notified, allowing them to resume execution.
Can you explain a scenario where `notifyAll()` might be preferred over `notify()` in a multithreading program?