Okhttp3 需要为一个对象设置唯一的属性值,比如对于 readtimeout。

huangapple go评论56阅读模式
英文:

Okhttp3 needs to make unquie properties value like readtimeout for one object

问题

在okhttp3中,诸如readtimeout值之类的属性值会针对每个连接更改,但工厂对象将是单例的。
当两个线程同时建立连接时,它会覆盖readtimeout值吗?

英文:

In okhttp3 the properties value like readtimeout value will be changed for each but the factory object will be singleton.
Does it override the readtimeout value when two thread makes connection at same time

答案1

得分: 1

每个OkHttpClient实例都是独立的,可以安全地并发使用。如果您想在OkHttpClient实例之间共享资源,请使用newBuilder()创建一个构建器,该构建器与另一个实例共享所有内容。

英文:

Each instance of OkHttpClient is independent and safe for concurrent use. If you want to share resources between OkHttpClient instances, use newBuilder() to make a builder that shares everything with another instance.

huangapple
  • 本文由 发表于 2020年7月23日 23:28:53
  • 转载请务必保留本文链接:https://go.coder-hub.com/63057807.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定