Java Multi-Threading Interview Preparation Guide
Enhance your Java Multi-Threading interview preparation with our set of 36 carefully chosen questions. Our questions cover a wide range of topics in Java Multi-Threading to ensure youre well-prepared. Whether youre new to the field or have years of experience, these questions are designed to help you succeed. Dont miss out on our free PDF download, containing all 36 questions to help you succeed in your Java Multi-Threading interview. Its an invaluable tool for reinforcing your knowledge and building confidence.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.
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.
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.
5 :: Name the methods available in the Runnable Interface?
run()
6 :: Name the methods available in the Thread class?
isAlive(),
join(),
resume(),
suspend(),
stop(),
start(),
sleep(),
destroy()
join(),
resume(),
suspend(),
stop(),
start(),
sleep(),
destroy()
7 :: Write the signature of the constructor of a thread class?
Thread(Runnable threadobject,String threadName)
{
}
{
}
8 :: Name the methods used for Inter Thread communication?
wait(),
notify() &
notifyall()
notify() &
notifyall()
9 :: Name the mechanism defined by java for the Resources to be used by only one Thread at a time?
Synchronisation
10 :: What is the sleep() method Data type for the parameter?
long