java Singleton模式的使用 [英] java Singleton pattern use

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

问题描述


除了创建数据库连接对象之外,我们还可以在哪里实时使用Singleton设计模式?
在此先感谢您.

Hi,
Where can we use Singleton design pattern in real time other than creating database connection object?
Thanks in advance.

推荐答案

请参阅我对问题的评论.首先,最后要意识到您不是实时工作.你什么意思只是个误称.如果您不知道单词的含义,请不要使用单词.

现在,您需要学习单例的工作原理和作用.请参阅:
http://en.wikipedia.org/wiki/Singleton_pattern [
—SA
Please see my comments to the question. First of all, finally realize that you are not working in real time. What do you even mean? Just a misnomer. Don''t use words if you have no clue what they mean.

Now, you need to learn how singleton works and what it does. Please see:
http://en.wikipedia.org/wiki/Singleton_pattern[^] (Java code sample is included here).

Then, the problem is the this is the second your question which give strong impression that you are not learning programming but trying to learn how to talk about programming. I sometimes call it "blah-blahology" :-). The thing is: to learn programming, you should solve problems. When you people problems, the usually find out that they really want to use a singleton, even where more experienced developer would avoid it. So, the real knowledge is learning how to avoid singletons, and the problem where to use them is usually never even posed. When you are solving many problem, it comes to your mind very often. If I gave you just one example, it would only push your out of understanding of this problem.

—SA


这篇关于java Singleton模式的使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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