You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You have basically re-discovered Amdalh's law. Creating the threads and maintaining the queue costs time and the code you execute in the threads is very short. Also, it probably synchronizes on the output as well.
Creating a thread does not mean that dealing with tasks will be fast. u create a pool with 10 threads. creating thread is quiet more expensive than u think. That's exactly why we need threadpool , avoiding create and destroy threads too many times
I test the threadpool with this code:
I found thread pool cost 5s, but loop just cost 0.005s
why threadpool not speed up?
The text was updated successfully, but these errors were encountered: