CompletableFuture eventual race condition

Pavel Rappo pavel.rappo at oracle.com
Mon Jul 11 19:29:40 UTC 2016


> On 11 Jul 2016, at 18:44, Francois Green <francois.green at gmail.com> wrote:
> 
> I sorry for posting in list, but I need an authoritative answer.  I was
> told by one of the developers of another JVM (Ceylon) language that
> 
> CompletableFuture.supplyAsync(() -> "Hejjo Worjd from Java")
>        .thenApply(s -> s.replaceAll("j","l"))
>        .thenAccept(System.out::println);
> 
> would eventual fail to print if run enough times.  Is this true?

Your snippet looks correct to me.

You could use jstress [1] to try to catch the alleged bug. And in case you
succeed, you could then produce a sscce as Martin suggested.

--------------------------------------------------------------------------------
[1] http://openjdk.java.net/projects/code-tools/jcstress/



More information about the core-libs-dev mailing list