How can multithreading speed up an application (when threads can't run concurrently)?

前端 未结 9 2015
忘掉有多难
忘掉有多难 2020-12-31 09:11

I\'m learning about multithreading, but after reading some tutorials I\'m sort of confused. I don\'t understand how multithreading can speed up an application.

By in

9条回答
  •  星月不相逢
    2020-12-31 09:56

    The idea behind multithreading is to have as few blocking points as possible. In other words, if a thread has to constantly wait on another thread to finish something, then the benefit of threads is likely lost in that situation.

    Obligatory link: http://en.wikipedia.org/wiki/Amdahl's_law

    Also, as Mark Ransom said, if your hardware can't actually do more than 1 thing at once, then threads are really just logically running at the same time (by swapping) than actually running at the same time. That can still be useful in situations with IO blocking though.

提交回复
热议问题