Java concurrency vs parallelism

Concurrent processing – when application is making progress on multiple tasks (concurrently) switching while executing from one task to another. One task may not be completely finished when the next task is started to be processed. Opposite to that is sequential processing of tasks – one at the time and one after another.

Parallel processing – when a task can be split by application into smaller units of work processed independently (parallely) at the same time especially on multicore/cpu machines. The opposite to parallel processing of a task is serial processing from start to end.

When the machine has very busy cpu doing other work (e.g. web server or db on the same box) then parallel or concurrent may give little gain or even loss. Splitting work execution across different cpu/core requires additional coordination that comes with an overhead. If a task is considerably small it may not worth functional parallel nor concurrent processing. Measure it.

Note that IO operations are not so CPU intensive and are good candidates for functional parallelism e.g. getting an aggregated result from data coming from different subsystems like e.g. http web resources.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s