Singleton and repackaged instance of Android okhttp

Singleton and repackaged instance of Android okhttp

Previously, when looking at the okhttp source code, I found that square did not make a single example of okhttpclient, and I didn't find a suitable explanation on the Internet. The following is my guess

Advantages: using singleton mode avoids the garbage generated by multiple creation

Disadvantages: it is difficult to implement singleton mode for some flexible configuration of code with special requirements

Summary: as an excellent open source framework, square aims to make users use and expand better and more flexibly. From the user's point of view, for projects that do not need multiple configurations, you can manually write a single instance mode to facilitate the efficient use of memory

Finally, we dedicate the last encapsulation class

In the class of JSON to model, too many performance problems were not considered at that time. Org.json.jsonobject and gson were used in this class. Corresponding optimization can be made here

If you have any questions, please leave a message or go to the community of this site for exchange and discussion. Thank you for reading. I hope it can help you. Thank you for your support to this site!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>