Single Instance vs. Static class

Source: Internet
Author: User

Here, only differences are discussed, and usage is not discussed.

I am more concerned about the time, use, and use.

 

 

  Static) Singleton)
Level: Class Level Object level
Features: One copy
One copy
Keep a global object instance
Memory storage: Category Category
One copy
Restrictions: Only static attributes and methods can be maintained Unlimited
Restrictions: It cannot be inherited or overloaded and cannot implement interfaces. Unlimited
Initialization: Delayed Initialization Delayed Initialization
Internal implementation: Static The internal implementation of the Singleton is also static.
Multi-thread concurrent access: Equivalent Equivalent
Performance: Equivalent Equivalent

 

Comparison, comparison, still do not see the big difference... Nothing unexpected ..

 

Discuss the singleton mode and static class again: http://raychase.iteye.com/blog/1471015

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.