wait() releases an object's monitor and suspends the calling thread until notification or interruption. It lets a consumer pause when no value is available and lets a producer pause when a list is full. section 7.3
Use wait() with a monitor-protected condition:
- Enter a synchronized block for the shared list. section 7.3
- Treat waiting as a performance cost to measure, not automatically an optimization. section 7.3
A slower producer-consumer run
A consumer and producer each loop 1,000,000 times over a shared list capped at 100 values. Adding wait() reduces lock frequency but increases waiting time; execution grows from about 9 seconds to about 50 seconds. section 7.3



