question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

unreasonable Thread Usage.

See original GitHub issue

Hi there ! , i am wondering why okhttp create new threads even when i use it Synchronous. here is my sample code :

//Thread.activeCount() return 1

OkHttpClient client = new OkHttpClient();

//this line create 2 new threads but why ? , what's wrong with using current thread ?!
Response response = client.newCall(new Request.Builder().url("https://google.com").get().build()).execute();

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
swankjessecommented, Aug 20, 2016

It’s explained here. No plans to change that. https://github.com/square/okhttp/wiki/Concurrency

0reactions
swankjessecommented, Aug 20, 2016

Yeah, but that library doesn’t use HTTP/2. OkHttp only spins up another thread for HTTP/2.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why Too Many Threads Hurts Performance, and What to do ...
First, partitioning a fixed amount of work among too many threads gives each thread too little work that the overhead of starting and ......
Read more >
Best Thread Count for Sheets | Sleep Foundation
Looking for sheets with a reasonable thread count (200-600 for most ... inflate the thread count is to use double- or triple-ply threads, ......
Read more >
Thread Count Guide: What Does It Mean for Sheets & Bedding?
Anything with a thread count nearing (or above) 1000 thread count is almost certain to be significantly lower quality than sheets with a...
Read more >
The Most Responsible Fabric on the Planet: Q&A With Thread
Thread produces fabrics from plastic bottles found in the streets of some of the poorest communities on earth, providing jobs to thousands ...
Read more >
What constitutes proper use of threads in programming?
For a web server it might be reasonable to fire a thread for each incoming connection (although there are better ways for very...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found