Created
February 2, 2015 13:52
-
-
Save andyHa/77f7be2ce87ae06ca03f to your computer and use it in GitHub Desktop.
Async Demo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Watch w = Watch.start(); | |
int msgs = 10_000_000; | |
AtomicInteger received = new AtomicInteger(); | |
for (int i = 0; i < msgs; i++) { | |
Async.defaultExecutor().start(() -> { | |
Async.defaultExecutor().start(() -> { | |
int numReceived = received.incrementAndGet(); | |
if (numReceived % 500_000 == 0) { | |
System.out.println(numReceived + " " + w.duration()); | |
} | |
}).execute(); | |
}).execute(); | |
} | |
while (received.get() < msgs) { | |
Wait.millis(100); | |
} | |
System.out.println(w.duration()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment