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
Why we do exception handling in java and how many types of exceptions are there?
How do you get the length of a string in java?
How do you decide when to use arraylist and linkedlist?
What is keyword and identifier?
Is an integer an object?
Why is java logo a cup of coffee?
What is the purpose of the enableevents() method?
Explain the difference between abstract class and interface in java?
What is the purpose of abstract class?
How to create a fecelet view?
Which keyword specify that a variable is effectively final ?
Can a source file contain more than one class declaration?
What is the difference between a local variable and an instance variable?
What is udp in java?
Why call by value prevents parameter value change?