Java Threads & Concurrency Interview Questions

    Question 1JAVA - Thread Creation

    Which of the following is a correct way to create a thread in Java?

    Question 2JAVA - Start vs Run

    What happens if you call the run() method directly instead of start() on a thread?

    Question 3JAVA - Runnable Example

    What will this code print?

    class MyTask implements Runnable { public void run() { System.out.println("Task executed"); } } public class Test { public static void main(String[] args) { Thread t = new Thread(new MyTask()); t.start(); } }

    Question 4JAVA - Sleep Method

    What does Thread.sleep(1000) do?

    Question 5JAVA - Synchronization

    Why is synchronization used in multithreading?

    Question 6JAVA - Deadlock Example

    What is a deadlock?

    Question 7JAVA - Executor Framework

    Which class provides factory methods for creating thread pools?

    Question 8JAVA - Callable vs Runnable

    Which is true about Callable vs Runnable?

    Question 9JAVA - Volatile Keyword

    What does the volatile keyword ensure in Java?

    Question 10JAVA - ReentrantLock Example

    Which advantage does ReentrantLock have over synchronized?