Blog Archives
1 2 3

08: 7 basic Java Executor framework Interview Q&As with Future & CompletableFuture

Basic level Java Executor framework Interview Q&As with Future & CompletableFuture (introduced in Java 8), which you would be using very often in Java apps. Q01. What is an Executor Framework? A01.In Java 5, Executor framework was introduced with the java.util.concurrent. … Read more ›...



08: CompletableFuture monadic chaining with examples – part 2

This extends Java FP – CompletableFuture monadic chaining with examples – part 1. f and g are processed asynchronously, and then combined A “Supplier” returns a result by taking nothing as an argument. “CompletableFuture.supplyAsync” executes a “Supplier” without blocking. This means executes it asynchronously. … Read more ›...



09: Java FutureTask example

Java 5 introduced the concurrent package for more efficient multi-threading.

Q. What is the difference between Future and FutureTask in asynchronous processing?
A. Future is the interface and FutureTask is the base implementation of the Future with methods to start and cancel a computation.

Read more ›



10: ExecutorService Vs Fork/Join & Future Vs CompletableFuture Interview Q&As

Q1. What is the difference between “ExecutorService” and “Fork/Join Framework“?
A1. The Fork/Join framework uses a special kind of thread pool known as the ForkJoinPool, which is a specialized implementation of ExecutorService implementing the 1) work-stealing algorithm,

Read more ›



14: Java Thread stop, resume, suspend & interrupt interview Q&As

Q1. Why are Thread.stop, Thread.suspend and Thread.resume deprecated? A1. We already learnt that “In Java programming, each object has a lock. A thread can acquire the lock for an object by using the synchronized keyword.” “The JVM uses locks in conjunction with monitors. … Read more ›...



15+ Java beginner multithreading interview Q&As

Q1. What is a thread?
A1. It is a thread of execution in a program. The JVM (i.e. process) allows an application to have multiple threads of execution running concurrently. In the Hotspot JVM there is a direct mapping between a Java Thread and a native operating system (i.e.

Read more ›



Java ExecutorService with strategy design pattern to execute concurrently & sequentially

Java executor framework for running multi-threaded applications concurrently, sequentially, and with a strategy design pattern to switch between sequential and concurrent execution. 1. Running concurrently The output will be You can see more than 1 thread process 5 tasks concurrently. Try changing the Executors.newCachedThreadPool () to Executors.newFixedThreadPool(3) for max 3...



1 2 3

Java Interview FAQs

800+ Java Interview Q&As

Top