Search code examples
language-agnosticparallel-processingconcurrency

What is the difference between concurrent programming and parallel programming?


What is the difference between concurrent programming and parallel programing? I asked google but didn't find anything that helped me to understand that difference. Could you give me an example for both?

For now I found this explanation: http://www.linux-mag.com/id/7411 - but "concurrency is a property of the program" vs "parallel execution is a property of the machine" isn't enough for me - still I can't say what is what.


Solution

  • If your program is using threads (concurrent programming), it's not necessarily going to be executed as such (parallel execution), since it depends on whether the machine can handle several threads.

    Here's a visual example. Threads on a non-threaded machine:

            --  --  --
         /              \
    >---- --  --  --  -- ---->>
    

    Threads on a threaded machine:

         ------
        /      \
    >-------------->>
    

    The dashes represent executed code. As you can see, they both split up and execute separately, but the threaded machine can execute several separate pieces at once.