Answer Posted / rajani nagandla
With respect to multithreading, Synchronization is a
process of controlling the access of shared resources by
the multiple threads in such a manner that only one thread
can access a particular resource at a time. In non
synchronized multithreaded application, it is possible for
one thread to modify a shared object while another thread
is in the process of using or updating the object's value.
Synchronization prevents such type of data corruption which
may otherwise lead to dirty reads and significant errors.
E.g. synchronizing a function:
public synchronized void Method1 () {
// method code.
}
E.g. synchronizing a block of code inside a function:
public Method2 (){
synchronized (this) {
// synchronized code here.
}
}
| Is This Answer Correct ? | 10 Yes | 3 No |
Post New Answer View All Answers
Is java util list serializable?
How to find the largest value from the given array.
Explain different forms of polymorphism?
What are inbuilt functions in java?
What is a top level class in java?
What are the 4 types of characters?
What is oops in java?
What is difference between java and java ee?
How many techniques can be employed to create a string object?
What is the difference between throw and throws in java?
Are static members inherited to sub classes?
How do you write methodology?
What is the size of int in 64-bit jvm?
What is set and get methods in java?
Is java 11 paid version?