Created
April 21, 2017 07:38
-
-
Save Dnomyar/3bb7b35c34760f212aafa32d6b284f87 to your computer and use it in GitHub Desktop.
Concurrence test using Stream API (.parallel() method)
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
public class TestConcurrence { | |
public static void main(String[] args) { | |
String address = "http://localhost:8080/servicejava/serverStatefull"; | |
System.out.println("*****************************"); | |
final WebTarget target = AppliCliente.clientJAXRS().target(address); | |
final Automate automate = WebResourceFactory.newResource(Automate.class, target); | |
int NB_REQUEST = 1000; | |
final long count = Stream.iterate(0, i -> i + 1) | |
.limit(NB_REQUEST) | |
.parallel() | |
.map(i -> automate.initier().getNumero()) | |
.distinct() | |
.count(); | |
System.out.println(count + "/" + NB_REQUEST); | |
System.out.println("*****************************"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment