Multithreading

From DmWiki

Multithreading, also called concurrency, is a programming language feature which allows the programmer to construct multiple independent "threads" of execution. This allows applications to be executing multiple functions simultaneously, and can be a useful programming model in many situations. For instance, you might want an application to be able to perform a complex operation (such as loading a file from disk) without hanging its user interface. In this case, the file-loading function could be in a separate thread from the user interface functions.

Multithreading will become increasingly important in the future, as the market trends toward dual-core processors and multi-processor setups. With multiple cores or processors, threads really do execute independently (as opposed to being serialized on a single processor, as before), and so only multithreaded applications will be able to take advantage of the power gained by a second processor core.

Designing multithreaded programs can be quite challenging. The primary problem occurs when application data must be shared between multiple threads; then two threads can be trying to write to the data at the same time, or one thread can be reading and one thread can be writing; this is known as a "race condition" and bugs caused by it can be very difficult to track down. Some languages, such as Java, include language features to assist in preventing race conditions; others, such as C++, provide no support but depend on the programmer (and the operating system) to ensure that threads do not interfere with one another.


Wikipedia : Thread (computer science) (http://en.wikipedia.org/wiki/Thread_%28computer_science%29)

This article is a stub. You can help improve the article by expanding it.

DevMaster navigation