• 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

use-case for parallel/concurrent programming

 
Ranch Hand
Posts: 572
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
What do you consider a good use case for parallel/concurrent programming?

Thanks,
Paul

[Devaka: Edited to add a meaningful subject line]
 
author
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

paul nisset wrote:
What do you consider a good use case for parallel/concurrent programming?



I'd say, whenever it either improves the performance by a noticeable amount (if something is fast enough single-threaded, why bother with multi-threading?) or makes the programming easier. Basically, if there is some natural parallelism in the program that can be exploited, and it's worth the effort.
 
paul nisset
Ranch Hand
Posts: 572
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you. I guess what I was asking is there a class of applications that lend themselves more naturally to Parallelism? For example a web service or a heavily used web app where each user session might get routed into one of several threads from a pool of threads ?
 
Bartender
Posts: 4116
72
Mac TypeScript Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

paul nisset wrote:... For example a web service or a heavily used web app where each user session might get routed into one of several threads from a pool of threads ?


In general each request for a web application is handled by a separate thread, this is implemented by the application/web servers.
 
Sergey Babkin
author
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, it's a good example. That's why the cloud computing can use a lot of parallelism: it handles a lot of inherently parallel requests.

Sometimes you can add the parallelism by partitioning the data in some obvious way. For example, if you handle the stock quotes, each stock symbol is handled independently from the others. So you can separate them into multiple threads, each one handling its own subset of symbols. As long as some data is independent from the others, it can always be separated into another thread. The difficulties start when the dependencies in the data processing appear.
 
Ranch Hand
Posts: 67
Eclipse IDE Debian Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can find parallelism everywhere. Some examples:
- If you have a user interface which is not responsive, then this might be due to a long running task. A nice way to handle such a thing is to keep that long running task out of the main user interface thread and run it in the background. Then you may be able to only block a small part of the user interface while that task is running. This "pattern" is used a lot in the Eclipse IDE user interface for example.
- If you want to speed up a long running server task, then often such a task can be broken up in some parallel tasks. In such a case I draw the server process in a diagram (e.g. UML activity diagram). If you do not think parallel, then often you draw a sequential diagram, but often a lot of these sequential steps are unrelated to each other and may be performed in parallel. For example:
Sequential:
Start -> Validate order -> Persist order -> Update customer -> Inform logistics -> Send customer e-mail -> End

Parallel (the update customer, inform logistics and send customer e-mail can be executed in parallel):
Start -> Validate order -> Persist order -> (Update customer | Inform logistics | Send customer e-mail) -> End
- The example which has been already mentioned, a system (e.g. web application) with multiple input channels (e.g. user sessions) which may not interfere.

Finally don't over-parallelize, as Sergey indicated, there is no need to complicate things if there is nothing to gain. On the other hand I advise you to experiment with it, because a lot of things look complicated when you have never done them before. And as you get more and more experienced with the subject and your tool set grows, you will be able to handle more difficult problems with more ease.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic