Okhttp uses OkHttpClent to send requests.
can I use the same OkHttpClent instance to requests in different Threads ?
Yes. OkHttpClient is thread safe, and the use case you describe is expected. Do not create a new client instance per thread.
But at the same time, consuming a single Response from multiple threads is probably unwise.
See docs here https://square.github.io/okhttp/4.x/okhttp/okhttp3/-ok-http-client/#okhttpclients-should-be-shared
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.