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 byte order of byte buffer?

563


What is the difference between yielding and sleeping in java programming?

586


how to split string in java?

654


Can the interface be final?

580


What is set and get methods in java?

543






Can we access the non-final local variable, inside the local inner class?

516


Explain wait(), notify() and notifyall() methods of object class ?

597


Are there structures in java?

554


Difference between nested and inner classes ?

610


What is serial version uid and its importance in java?

598


What is double in java?

517


What is collection api?

610


Can a class extends itself in java?

528


What is a blocking method in Java?

606


Can we override constructor?

538