Is there a difference between concurrency and parallelism in java?

前端 未结 8 1403
时光说笑
时光说笑 2021-01-30 13:35

I have been doing some research in Google and cant quite get my head around the differences (if any) between concurrent and parallel programs in java. Some of the information I

8条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-30 14:22

    If you program 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.

    Please refer this What is the difference between concurrent programming and parallel programming?

提交回复
热议问题