具有连接池的单例模式 [英] Singleton pattern with connection pooling

查看:88
本文介绍了具有连接池的单例模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以在ASP.net中的连接池中使用单例设计模式吗?

如果不是为什么?

Can I use singleton desgin pattern with connection pooling in ASP.net?

If not why?

Thanks in advance!

推荐答案

您的问题中没有足够的内容可以给出明确的答案.我们需要知道应该将单例模式确切地应用于哪个类,以及该类的责任是什么.

根据您的要求,我会说在适用的情况下使用单例是很好的.如果要在多线程环境中使用该类,则必须确保该类是线程安全的.

干杯!

曼弗雷德(Manfred)
There is not enough substance in your question to give a definite answer. We would need to know to what class exactly the singleton pattern is to supposed to be applied and what the responsibility of that class is.

Depending on your requirements I''d say that it''s fine to use a singleton wherever applicable. You do have to make sure though that the class is threadsafe if it will be used in a multithreaded environment.

Cheers!

Manfred


这篇关于具有连接池的单例模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆