Java : Singleton class instances in a Web based Application

Posted by Preethi Jain on Stack Overflow See other posts from Stack Overflow or by Preethi Jain
Published on 2012-09-22T15:33:40Z Indexed on 2012/09/22 15:37 UTC
Read the original article Hit count: 169

Filed under:

I have this Singleton class inside a Web Application .

public class MyDAO 
 {


    private static MyDAO instance;

    private MyDAO() {
    }

    public static MyDAO getInstance() {
        if (instance == null) {
            instance = new MyDAO();
        }
        return instance;
    }

I will access it this way

public void get_Data()
{

        MyDAO dao = MyDAO.getInstance();
}

How many Objects of MyDAO class will be created if there are 3 Users accessing the Application ??

Will there be one instance of MyDAO per User ??

© Stack Overflow or respective owner

Related posts about java