Java Threading Interview Questions and Answers - Freshers & Experienced!

What is a thread? - Threads allow programs to execute simultaneously. A thread is an independent path of execution in a program...
How to create a thread and start it running? - There are 2 ways in which a thread can be created...
How does thread’s stop method work - Stop() method of thread stops the thread execution...
How do we specify pause times in my program? - Using the sleep function in Java, the thread’s execution can be put on hold. During this pause session....
Multithreaded program and importance of thread synchronization - A multithreaded program involves multiple threads of control in a single program. Each thread has its own stack...
When a thread is created and started, what is its initial state? - A thread is in “Ready” state after it has been created and started...
What are the high-level thread states? - The thread can be in one of the following states: Running state, Ready state, Dead state and Waiting state...
Preemptive scheduling and time slicing - Under Preemptive scheduling, the task with the highest priority is executed until it enters the waiting or dead states...
What is a task's priority and how is it used in scheduling? - Every task is assigned a priority for execution. The task with the highest priority is executed first...
What is a monitor? - The mechanism that Java uses to support synchronization is the monitor...
Use of synchronization keyword - A method, declared as synchronized, first attains a lock over an object before beginning an execution...
How do we allow one thread to wait while other to finish? - The wait method, notify method, and notifyAll method provide an efficient transfer of control from one thread to another...
Purpose of yield method - The yield method causes the currently executing thread object to temporarily pause...
Yielding and sleeping - The sleep() causes the thread to suspend its running only for a specified amount of time, The yield() causes the thread to join the ready queue in the CPU again...