What is the difference between Thread.sleep() and Thread.yield()?
Q.2Medium
What is the purpose of the synchronized keyword in Java multithreading?
Q.3Medium
Which of the following is NOT a thread state in Java?
Q.4Medium
What will be the output of calling start() multiple times on the same thread object?
Q.5Medium
What is a race condition in multithreading?
Advertisement
Q.6Medium
Consider a synchronized method. Can multiple threads call it simultaneously on the same object?
Q.7Medium
What is the difference between notify() and notifyAll()?
Q.8Medium
Which class provides thread-safe operations on shared variables in Java?
Q.9Medium
What is a daemon thread in Java?
Q.10Medium
What is a deadlock in multithreading?
Q.11Medium
What is thread pooling and which class is commonly used for it?
Q.12Medium
What will be the output of the following code snippet?
java
class Test extends Thread {
public void run() {
System.out.print("T");
}
}
public class Main {
public static void main(String[] args) {
Test t = new Test();
t.run();
t.start();
}
}
Q.13Medium
Consider a scenario where Thread A acquires Lock1 and tries to acquire Lock2, while Thread B acquires Lock2 and tries to acquire Lock1. What situation arises?
Q.14Medium
Which of the following is a thread-safe collection in Java that can be used without explicit synchronization?
Q.15Medium
What happens if you call interrupt() on a thread that is not in a waiting or sleeping state?
Q.16Medium
Which method is used to check the current state of a thread in Java?
Q.17Medium
In the context of synchronized methods, what is acquired and released automatically?
Q.18Medium
What is the main advantage of using ExecutorService over directly creating threads?
Q.19Medium
In a multithreaded application, what does the term 'context switching' refer to?
Q.20Medium
In Java 21 (latest), which is a modern approach to create thread-safe operations?