Example usage for java.util.concurrent.atomic AtomicReference notifyAll

List of usage examples for java.util.concurrent.atomic AtomicReference notifyAll

Introduction

In this page you can find the example usage for java.util.concurrent.atomic AtomicReference notifyAll.

Prototype

@HotSpotIntrinsicCandidate
public final native void notifyAll();

Source Link

Document

Wakes up all threads that are waiting on this object's monitor.

Usage

From source file:io.fabric8.agent.download.DownloadManagerTest.java

private StreamProvider download(DownloadManager manager, String url) throws Exception {
    final AtomicReference<StreamProvider> ref = new AtomicReference<>();
    Downloader downloader = manager.createDownloader();
    downloader.download(url, new DownloadCallback() {
        @Override//from ww w .j a v a  2 s  .c o  m
        public void downloaded(StreamProvider provider) throws Exception {
            synchronized (ref) {
                ref.set(provider);
                ref.notifyAll();
            }
        }
    });
    synchronized (ref) {
        ref.wait(30000);
        return ref.get();
    }
}