Java Multi-Threading Question:
Download Questions PDF

What is thread synchronization?

Java Multi-Threading Interview Question
Java Multi-Threading Interview Question

Answer:

In multithreading, the shared resources are allocated to one thread at a time.
multiple thread ensuring that the shared resources will be allocated to only one thread at a time is called thread synchronization.
The synchronized keyword is used to define the critical block in which every Java object get a lock to enter.

Syntax:

Synchronized(object) // object is reference of the object to be synchronized
{
// statement to be synchronized.
}
The synchronized keyword provides locking which maintain the mutual exclusive access of shared resource and race of objects for data.

Download Java Multi-Threading Interview Questions And Answers PDF

Previous QuestionNext Question
Explain Preemptive scheduling and time slicing?Explain the difference between preemptive scheduling and time slicing?