question on Thread synchronization

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


Please Help Members By Posting Answers For Below Questions

What is the difference between exception and error in java?

486


What is parsing in java?

526


What is the use of generics? When was it added to the Java development Kit?

551


What is class forname used for?

533


What are the classes of java?

531






Is a class subclass of itself?

596


Program to Find the second largest element in an array.

580


What is the importance of hashcode() and equals() methods?

572


What is private static in java?

571


What is re-factoring in software?

567


What is the difference amongst jvm spec, jvm implementation, jvm runtime ?

500


What are the different types of sorting in java?

539


Describe the Big-O Notation.

611


Distinguish between a predicate and a function?

561


How do you delete a list in java?

524