Java Multi-Threading Interview Preparation Guide
Download PDF

Java multi-threading frequently Asked Questions by expert members with experience in Java Multi-Threading. These interview questions and answers on Java multi-threading will help you strengthen your technical skills, prepare for the interviews and quickly revise the concepts. So get preparation for the Java multi-threading job interview

36 Java Multi-Threading Questions and Answers:

1 :: Explain Preemptive scheduling and time slicing?

In preemptive scheduling, the highest priority task executes until it enters the waiting or dead states or a higher priority task comes into existence.

In time slicing, a task executes for a predefined slice of time and then reenters the pool of ready tasks.
The scheduler then determines which task should execute next, based on priority and other factors.
Briefly explain daemon thread.

Daemon thread is a low priority thread which runs in the background performs garbage collection operation for the java runtime system.

2 :: What are the two types of multitasking?

Two types of multitasking are Process-based and Thread-based

3 :: Difference between Process and Thread?

A process can contain multiple threads.
A process has its own memory address space whereas a thread doesn't.
Threads share the heap belonging to their parent process.
One process cannot corrupt another process
A thread can write the memory used by another thread.

4 :: What is time slicing?

Timeslicing is the method of allocating CPU time to individual threads in a priority schedule.

6 :: Name the methods available in the Thread class?

isAlive(),
join(),
resume(),
suspend(),
stop(),
start(),
sleep(),
destroy()

7 :: Write the signature of the constructor of a thread class?

Thread(Runnable threadobject,String threadName)
{

}

9 :: Name the mechanism defined by java for the Resources to be used by only one Thread at a time?

Synchronisation