Friday, April 6, 2012

Introduction to Java Concurrent Programming

When computers didn't have operating systems yet, they executed only one program at the time. The program would run from the beginning to the end. Running only one program was the only way back then, and this is now seen as very inefficient. Because the program had access to all the resources in the computer at any time, programming was a lot simpler. But because the machine (computer) was only running once program at the time, the machine's resources where not used efficiently, resulting in an inefficient use of the computers capabilities. Nowadays, machines are able to run multiple programs. The OS (operating system) can even run multiple programs simultaneously, and one single program can even be divided into multiple concurrent threads. All these threads together do all the work that used to be done by just one program. Threads can also communicate with each other, with for instance; message passing and shared memory concurrency.

The last few years, multicore processors have become less expensive. Most desktop computers and laptops are using multicore chips and developers are programming more and more with multiple concurrent threads. A downside is that the bug reports related to threading are also increasing every day; this shows that multicore programming is not the easiest thing to do. In Java, concurrency bugs are one of the most painful problems and in many occasions they are highly unpredictable. One of the biggest issues regarding Java concurrent programming is the mind-set of the programmers that doesn't match the concurrency features offered in Java. Programmers need to start thinking about concurrency and parallelism in the foundation of their programs. The Java language provides low level tools for concurrency such as condition waits, synchronization, message passing and resource sharing. The problem is that these tools need to be implemented at application level consistently. The conclusion? It can already be hard to write correct programs, but writing correct concurrent programs is even harder. The right mind-set is needed. The reason behind the high difficulty level is that there are simply more levels where things can go wrong with Java concurrent programming. The reason developers still choose to use concurrency on their programs is because threads are an inevitable feature of the Java language and the easiest way to use the multicore power we see almost everywhere these days. When looking are the future, the only conclusion that can be made is that concurrency programming will become increasingly important with the rising number of cores.

For more information regarding Java concurrent programming, please visit www.ateji.com.



Article Source: http://EzineArticles.com/6401289

1 comment: