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
How is treeset implemented in java?
What does pointer mean?
What is the use of flag?
Why does java not allow multiple public classes in a java file ?
Explain reverse a linked list iterative solution in java?
What is java reflection?
What are the advantages of encapsulation in java?
Explain the difference between extends thread vs implements runnable in java?
What is the difference between instanceof and isinstance?
What is the symbol for space?
we have syntax like for(int var : arrayName) this syntax is to find whether a number is in the array or not.but i want to know how to find that number's location.
Why we used vector class?
What is the meaning of I ++ in java?
What is private public protected in java?
Why wait(),notify(),notifyAll() methods defined in Object class althought we are using in only threads.