Which method is used to check the current state of a thread in Java?
Q.162Medium
In the context of synchronized methods, what is acquired and released automatically?
Q.163Medium
What is the main advantage of using ExecutorService over directly creating threads?
Q.164Medium
In a multithreaded application, what does the term 'context switching' refer to?
Q.165Medium
In Java 21 (latest), which is a modern approach to create thread-safe operations?
Advertisement
Q.166Medium
What will be the output of the following code?
Object lock = new Object();
synchronized(lock) {
synchronized(lock) {
System.out.println("Nested");
}
}
Q.167Medium
Which interface would you use to submit multiple tasks and wait for all of them to complete?
Q.168Medium
What is the difference between notify() and notifyAll() in Java?
Q.169Medium
Which of the following best describes CyclicBarrier?
Q.170Medium
What happens when a thread acquires a lock on an object and then calls wait()?
Q.171Medium
In a scenario where Thread A holds Lock1 and waits for Lock2, while Thread B holds Lock2 and waits for Lock1, what is this called?
Q.172Medium
What is the output of this code?
ExecutorService executor = Executors.newSingleThreadExecutor();
executor.submit(() -> System.out.println("Task 1"));
executor.submit(() -> System.out.println("Task 2"));
executor.shutdown();
Q.173Medium
Which method is used to forcefully stop a thread in modern Java?
Q.174Medium
What happens if an exception is thrown inside a synchronized block?
Q.175Medium
In Java 21 Virtual Threads, what is the key advantage over platform threads?
Q.176Medium
What does the volatile keyword guarantee in Java multithreading?
Q.177Medium
What is the output of the following code?
volatile int counter = 0;
counter++; // in multiple threads
Which issue may occur?
Q.178Medium
What is CyclicBarrier used for in multithreading?
Q.179Medium
Which of the following is true about CountDownLatch?