Programming Tutorials

What do you understand by Synchronization?

By: Karthik in Interview Tutorials on 2012-06-16  

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.
         }
}





Add Comment

* Required information
1000

Comments

No comments yet. Be the first!

Most Viewed Articles (in Interview )

What is the difference between JTS and JTA?

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?

What are the life-cycle methods of JSP?

What types of comments are available in the JSP?

Question: What is an output comment in JSP?

Interview Question: What are the optional clauses in EJB QL?

Explain the different forms of Polymorphism.

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

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

What is J2EE?

Explain the new Features of JDBC 2.0 Core API?

Question: How would you go about analyzing performance of an application?

What do you understand by a container in J2EE?

Types of Interviews

Interview Question: What about JSTL and JavaServer Faces ?

Latest Articles (in Interview)