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
What is the difference between exception and error in java?
What is parsing in java?
What is the use of generics? When was it added to the Java development Kit?
What is class forname used for?
What are the classes of java?
Is a class subclass of itself?
Program to Find the second largest element in an array.
What is the importance of hashcode() and equals() methods?
What is private static in java?
What is re-factoring in software?
What is the difference amongst jvm spec, jvm implementation, jvm runtime ?
What are the different types of sorting in java?
Describe the Big-O Notation.
Distinguish between a predicate and a function?
How do you delete a list in java?