Blog Archives

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

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, in which the idle workers steal the work from those workers who are

Read more ›

Posted in Java 8, Multithreading, Reactive Programming

Producer and Consumer Java Multi-threading code

The following code is used for demonstrating thread-safety issues on eclipse. Step 1: ProducerConsumerTest

Step 2: Producer thread.

Step 3: Consumer thread.

Step 4: ProducerConsumer logic.

Key Points 1) The wait & notifyAll methods in the java.lang.Object class is used for inter-thread communication to wait for

Read more ›

Posted in Multithreading

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. The FutureTask provides asynchronous computation with

Read more ›

Posted in Multithreading

03: ♦ 5 Java multithreading scenarios interview questions answered

This extends Q1. Can you give some scenarios where you had used multi-threading in Java applications? Q2. Can you give some scenarios where you used the synchronized keyword in Java? A2. Firstly, you need to assume that your code is always going to be accessed by multiple threads. Scenario 1:…...

Members Only Content

This content is for the members with any one of the following paid subscriptions:

30-Day-Java-JEE-Career-Training, 90-Day-Java-JEE-Career-Training, 180-Day-Java-JEE-Career-Training, 365-Day-Java-JEE-Career-Training, 60-Day-Java-JEE-Career-Training and 2-Year-Java-JEE-Career-Training

Want to evaluate the quality of the contents to see if they will add value to you?

Click Here and check the contents with Try.

Log In | Register
Posted in Concurrency, member-paid, Multithreading
Tags:

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…...

Members Only Content

This content is for the members with any one of the following paid subscriptions:

30-Day-Java-JEE-Career-Training, 90-Day-Java-JEE-Career-Training, 180-Day-Java-JEE-Career-Training, 365-Day-Java-JEE-Career-Training, 60-Day-Java-JEE-Career-Training and 2-Year-Java-JEE-Career-Training

Want to evaluate the quality of the contents to see if they will add value to you?

Click Here and check the contents with Try.

Log In | Register
Posted in GoF Patterns, member-paid, Multithreading

06: ♦ 10+ Atomicity, Visibility, and Ordering interview Q&A in Java multi-threading

Q1. Why is it important to understand the difference between the “JVM memory model” and the computer “hardware memory model”? A1. 3 reasons why it is important to understand the JVM memory model and computer hardware memory model are: 1) JVM memory model and the physical hardware memory model architectures…...

Members Only Content

This content is for the members with any one of the following paid subscriptions:

30-Day-Java-JEE-Career-Training, 90-Day-Java-JEE-Career-Training, 180-Day-Java-JEE-Career-Training, 365-Day-Java-JEE-Career-Training, 60-Day-Java-JEE-Career-Training and 2-Year-Java-JEE-Career-Training

Want to evaluate the quality of the contents to see if they will add value to you?

Click Here and check the contents with Try.

Log In | Register
Posted in JVM, member-paid, Multithreading

07: 5 Basic multithreading interview questions & answers

1. What does Java thread join do? 2. What is the difference between start and run methods? 3. What is a daemon thread? 4. How are threads prioritized? 5. Is Java thread scheduling preemptive? Using a join( ) method means waiting for a thread to complete. In the example below,…...

Members Only Content

This content is for the members with any one of the following paid subscriptions:

30-Day-Java-JEE-Career-Training, 90-Day-Java-JEE-Career-Training, 180-Day-Java-JEE-Career-Training, 365-Day-Java-JEE-Career-Training, 60-Day-Java-JEE-Career-Training and 2-Year-Java-JEE-Career-Training

Want to evaluate the quality of the contents to see if they will add value to you?

Click Here and check the contents with Try.

Log In | Register
Posted in member-paid, Multithreading

08: ♦ ThreadLocal Interview questions & answers

Q1. What is a ThreadLocal class? When to use it? How to not abuse it? A1. ThreadLocal is a handy class for simplifying development of thread-safe concurrent programs by making the object stored in this class not sharable between threads. When to use? 1) ThreadLocal class encapsulates non-thread-safe classes (e.g.…...

Members Only Content

This content is for the members with any one of the following paid subscriptions:

30-Day-Java-JEE-Career-Training, 90-Day-Java-JEE-Career-Training, 180-Day-Java-JEE-Career-Training, 365-Day-Java-JEE-Career-Training, 60-Day-Java-JEE-Career-Training and 2-Year-Java-JEE-Career-Training

Want to evaluate the quality of the contents to see if they will add value to you?

Click Here and check the contents with Try.

Log In | Register
Posted in member-paid, Multithreading
Page 1 of 212
1100+ paid subscribers. Reviews | Free Contents. Monthly 260K+ views & 40k+ visitors. 9 tips to earn more.

Java Developer Training – 800+ Q&As ♥Free|♦FAQ (Mouse Hover for Tooltip)

open all | close all

200+ Java Developer Job Interview FAQs

open all | close all

16 Java Programmer Key Areas to be a top-notch

open all | close all

80+ Java Tutorials – Step by step

open all | close all

100+ Java Developer Coding Exercises

open all | close all

How good are your …..Java job hunting & career fast-tracking skills?

open all | close all