Sunday, August 23, 2009

Q. What is Singleton class?
Ans. Singleton class is a class whose only one object can be created at a time. - To achieve this one method is that we make its constructor private and provide a static method that returns its instance.
When a Singleton class is garbage - collected and then reloaded, a new Singleton instance is created.


Q. What is synchronization and why is it important?
Ans. With respect to multithreading, synchronization is the capability to control the access of multiple threads to shared resources. Without synchronization, it is possible for one thread to modify a shared object while another thread is in the process of using or updating that object's value. This often causes dirty data and leads to significant errors.

No comments:

Post a Comment