Concurrency

June 17, 2009

An aspect in computer science and software development that remains confusing to many of those who have studied it is known as Concurrency. Concurrency is the ability for multiple computations to be executed “simultaneously”. In the case of a machine with multiple processors, more than one set of computations can run at the same time. However, what happens in most cases is that the resources of the processor are shared.

When you run any program, a Thread is created. A thread is just a sequence of instructions. The regular way for a program to run is that the compiler will sequentially evaluate each statement in the program. Each statement must be evaluated before the next one. Think of each Thread being like its set of evaluations.

Using more than one Thread allows more than one set of statements to be evaluated simultaneously. It is rare for beginner programmers to use concurrency because there isn’t much need in most cases for multiple things to happen at once. However, if you think of the big picture, your computer would be a headache if there weren’t any concurrency. For example, your screen is repainting constantly as you use your computer. If there were no concurrency, if you loaded a program, everything else would simply cease to happen until the program were completely loaded. While your computer may only have one processor, using concurrency gives the illusion of multiple things happening at once.

In reality, your processor can still only go at a maximum speed. However, it will split time between the threads running, which will make everything look like its happening at the same time. This brings up a number of potential issues involving the fact that we cannot know in any predictable fashion how the processor will dedicate time – we will deal more with this later.

To recap, using concurrency and threads allows programs to do more than one series of computations at once. We will come back to this with both examples and discussion of the issues that arise.

One Response to “Concurrency”

  1. [...] causes potential problems that must be addressed. Here we will take a look at the most common ones. To recap and continue from our last article, concurrency allows multiple Threads to evaluate more than one set of statements at [...]

Leave a Reply