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 )

Interview Question: How is the MVC design pattern used in Struts framework?

Interview Question: Who wrote Struts?

Question: What is a Hidden Comment in JSP?

What are implicit Objects available to the JSP Page?

Explain the Encapsulation principle.

What is Collection API?

What is Deployment Descriptor?

Interview Question: What is Local client view in EJB?

Interview Question: Where can I get a copy of Struts?

Interview Question: What is the difference between Message Driven Beans and Stateless Session beans?

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

What is similarities/difference between an Abstract class and Interface?

Interview Question: What are the call back methods in Entity bean?

Question: Difference between forward and sendRedirect in JSP?

Question: What is an Expression tag in JSP?

Latest Articles (in Interview)