What do you understand by Synchronization?

By: Karthik  

Answer: 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 one 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.

E.g. Synchronizing a function:
public synchronized void Method1 () {
     // Appropriate method-related code. 
}
E.g. Synchronizing a block of code inside a function:
public myFunction (){
    synchronized (this) { 
            // Synchronized code here.
         }
}





Most Viewed Articles (in Interview )

Interview Question: Can i map more than one table in a CMP?

Explain the new Features of JDBC 2.0 Core API?

How to define an Abstract class?

Interview Question: What is Message Driven Bean?

Getting started with Interview

What is the difference between jsp:include page and @ include file?

Interview Question: Is it possible to share an HttpSession between a JSP and EJB? What happens when I change a value in the HttpSession from inside an EJB?

Interview Question: What is the difference between JavaBean and EJB?

Interview Question: What is abstract schema?

Interview Question: What is local interface. How values will be passed?

Interview Question: What is re-entrant. Is session beans reentrant. Is entity beans reentrant?

Interview Question: What is the difference between sessioncontext and entitycontext?

Interview Question: Is Decorator an EJB design pattern?

Interview Question: What is the difference between EAR, JAR and WAR file?

Interview Question: What is deployment descriptor?

Latest Articles (in Interview)

Comment on this tutorial