• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Concurrency vs Parallelism

 
Greenhorn
Posts: 17
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am confused between both these terms in java. As far as I know , concurrent execution of threads means executing the threads in an interleaved manner and parallelism means dividing the tasks into sub-tasks and executing them parallely.
When I was going through a article about fork and join framework on a site, it said that the fork and join framework helps in achieving parallelism but I read somewhere else that full parallelism can never be achieved. I find these both statements contradictory.
Also in fork and join framework is it that the threads execute concurrently but just on multiple cores? If fork and join framework can't help in achieving pure parallelism, is there a way to achieve it?

Thanks.
 
Ranch Hand
Posts: 180
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Parallelism means running multiple jobs in parallel on multiple CPUs. Concurrency generally means running multiple jobs, may or may not be on multiple CPUs.
 
Akshay Rathore
Greenhorn
Posts: 17
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So you say that parallelism is just like concurrency but here the jobs run on multiple CPU's?
 
Salil Wadnerkar
Ranch Hand
Posts: 180
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Concurrency means running multiple jobs. Parallelism is a specific case of concurrency where these jobs run on multiple CPUs. Note that you can run multiple jobs on a single CPU using a multi-tasking OS/runtime like JVM.
 
Akshay Rathore
Greenhorn
Posts: 17
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So fork and join framework just helps in achieving interleaving over multiple cpu's? If so, there isn't any way to achieve pure parallelism in java?
 
Salil Wadnerkar
Ranch Hand
Posts: 180
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As I already mentioned, running on multiple CPUs is parallelism
 
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Akshay Rathore wrote:. . . there isn't any way to achieve pure parallelism in java?

Have you not tried running a Stream in parallel?
 
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You could have a look at the Wikipedia articles for the two concepts (note that they aren't Java concepts, they are computing concepts): Concurrency (computer science) and Parallel computing.
 
Akshay Rathore
Greenhorn
Posts: 17
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:

Akshay Rathore wrote:. . . there isn't any way to achieve pure parallelism in java?

Have you not tried running a Stream in parallel?



Actually I was not familiar with Java 8 features but I read about parallel streams now and understood it. Can you please help with the question of fork and join framework which I have asked above?
 
Ranch Hand
Posts: 51
1
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I know this is an old post but wanted to add my thoughts.

Concurrency and Parallelism mean EXACTLY the same thing (even the above mentioned Wikipedia post conflates the terms, so I can see why you are confused). However, in my experience, the term 'concurrency' typically tends to be used (especially more recently with the advent of 'Big Data') when referring to tasks that are executed at the same in in a shared memory space (e.g. multiple concurrent threads in a JVM). Running in parallel, however, tends to refer to tasks that may, or may not (typically not) run in the same memory space (e.g. "shared nothing" architectures like Hadoop, where processes run 'in paralell' but cannot access eachother). Of course, sometimes the terms are used interchangeably which might cause confusion. For example, Erlang is a "shared nothing" language, but developers tend to talk about "concurrent processes" rather than parallel processes. Just my experience! Hope it helps.
 
Campbell Ritchie
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Theo van Kraay wrote:. . . Concurrency and Parallelism mean EXACTLY the same thing . . .

Are you quite sure about that?
 
Theo van Kraay
Ranch Hand
Posts: 51
1
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:

Theo van Kraay wrote:. . . Concurrency and Parallelism mean EXACTLY the same thing . . .

Are you quite sure about that?



Nope! I'm too used to posting on Facebook, where I can edit my shoddy posts when necessary. I had such powers here, I would remove that sentence altogether. Sincere appollo cheese.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic