Parallel coding Vs Multithreading (on single cpu)

前端 未结 7 1372
忘掉有多难
忘掉有多难 2020-12-30 13:11

can we use interchangeably \"Parallel coding\" and \"Multithreading coding \" on single cpu?

i am not much experience in both, but i want to shift my coding style t

7条回答
  •  抹茶落季
    2020-12-30 13:21

    I'm not sure about what do you think "Parallel coding" is but Parallel coding as I understand it refers to producing code which is executed in parallel by the CPU, and therefore Multithreaded code falls inside that description.

    In that way, obviously you can use them interchangeably (as one falls inside the other).

    Nonetheless I'll suggest you take it slowly and start learning from the basics. Understand WHY multithreading is becoming important, what's the difference between processes, threads and fibers, how do you synchronize either of them and so on.

    Keep in mind that parallel coding, as you call it, is quite complex, specially compared to sequential coding so be prepared. Also don't just rush into it. Just because you use 3 threads instead of one won't make your program faster, it can even make it slower. You need to understand the hows and the whys. Not every thing can be made parallel and not everthing that can, should.

提交回复
热议问题