Threads and Synchronization II
void notifyAll()
- These methods must be called from a synchronized method.
- These methods notify a waiting thread or threads.
notify() notifies the thread associated with the given synchronization object that has been waiting the longest time
notifyAll() notifies all threads associated with the given object and is therefore safer than notify()
One can mark a variable as "threadsafe" to inform the compiler that only one thread will be modifying this variable.