Java / Java Multithreading
Can a thread wait on multiple objects in Java?
A thread runs a Runnable or Callable. Prefer ExecutorService over raw Thread. Share state only with synchronization, volatiles, or concurrent collections.
No. A thread cannot wait on more than one object at a time.
The wait() and notify() methods are object specific and invoke on the object. The wait() method suspends the current thread of execution, and instructs the object to keep track of the suspended thread. The notify() method tells the object to wake up the suspended threads that it is currently keeping track of.
More Related questions...