CountDownLatch in Java

Why need CountDownLatch We will demo an example to show why we need the CountDownLatch class. It is known that when we call the methods of CompletableFuture, if the method is asynchronous, then the job is executed in a new thread. The asynchronous methods will have the postfix -Async in their name. While with the…

Basic methods of CompletableFuture class part 3

Basic methods of CompletableFuture class part 3 We will continue with the basic methods of CompletableFuture class. With the Fruit.java in the previous section: thenCombine and thenCombineAsync We know that the thenCompose() duo can chain 2 futures, one depends on the other, for example, in our previous example, the second CompletableFuture: must depend on the…

Basic methods of CompletableFuture class part 2

Basic methods of CompletableFuture class part 2 We will continue with the basic methods of CompletableFuture class. The Fruit.java in the previous section: thenCompose and thenComposeAsync methods These methods return a CompletableFuture from another CompletableFuture. Curiouser and curiouser, right? Yep, this one is hard, at first only :D. Now, the methods as their name suggests,…

Java Test 43

Java Test for Multithreading Don’t try to hack or to do something unusual, this is just some basic Java tests for multithreading, to see what we learned until now. Please try to finish these tests without using an IDE. After choosing your options (radio buttons) please press Check button to see the result. Note that…

Fork/Join Framework – RecursiveAction

Introduction to Fork/Join Framework The Fork/Join Framework was introduced from Java 7, and actually, not every Java developer seems to be happy with it. The Fork/Join will split (or fork) task into subtasks recursively, each subtask can be executed concurrently. The Fork/Join tasks and subtasks are submited to a special thread pools, the ForkJoinPool. Fork…