I have a thread which must wait several objects from different threads.
@Override
public void run() {
    while (true) {
        for (BackgroundTask task : tasks) {
            synchronized (task) {
                if (task.isReady()) {
                    task.doTask();
                }
            }
        }
    }
}
But it is a stupid use of CPU time. How to wait several objects?
 
     
     
     
    