Java Multithreading Interview Questions and Answers
The Best LIVE Mock Interview - You should go through before Interview
Freshers / Beginner level questions & answers
Ques 1. What is multithreading?
Multithreading is the concurrent execution of two or more threads to achieve parallelism in a program.
Example:
In Java, you can create a multithreaded program by extending the Thread class or implementing the Runnable interface.
Is it helpful?
Add Comment
View Comments
Ques 2. How do you create a thread in Java?
You can create a thread by extending the Thread class or implementing the Runnable interface.
Example:
Example using Thread class:
class MyThread extends Thread {
public void run() {
/* Thread logic */
}
}
Is it helpful?
Add Comment
View Comments
Ques 3. What is the purpose of the sleep() method in Java?
The sleep() method is used to pause the execution of the current thread for a specified amount of time.
Example:
try { Thread.sleep(1000); }
catch (InterruptedException e) { e.printStackTrace(); }
Is it helpful?
Add Comment
View Comments
Ques 4. What is the purpose of the yield() method?
The yield() method is used to make the currently executing thread voluntarily pause, allowing other threads to execute.
Example:
Thread.yield();
Is it helpful?
Add Comment
View Comments
Most helpful rated by users: