Content deleted Content added
m wording; disambiguation |
some rewording |
||
Line 1:
[[ja:スレッド (コンピュータプログラミング)]] [[pl:Wątek (informatyka)]] [[es:hilo(informática)]] [[de:Thread]]
Many [[programming language]]s, [[operating system]]s, and other [[software development]] environments support what are called "'''threads'''" of [[execution]]. [[Thread]]s are similar to [[computer process|processes]], in that both represent a single [[sequence]] of [[instruction]]s executed in parallel with other sequences, either by [[Computer multitasking|time slicing]] or [[multiprocessing]].
A common use of threads is having one thread paying attention to the [[graphical user interface]], while others do a long calculation [[Background (computer software)|in the background]].
As a result, the
Threads are distinguished from traditional multi-tasking [[computer process|processes]] in that processes are typically independent, carry considerable [[state information]], and interact only through system-provided [[inter-process communication]] mechanisms. Multiple threads, on the other hand, typically share the state information of a single process, share [[Computer storage|memory]] and other [[resource]]s directly. On [[operating system]]s that have special facilities for threads, it is typically faster for the system to [[context switch]] between different threads in the same process than to switch between different processes.
Systems like [[Windows NT]] and [[OS/2]] are said to have "cheap" threads and "expensive" processes, while in systems like [[Linux]] there is not so big a difference.
An advantage of a multi-threaded program is that it can operate faster on [[computer system]]s that have multiple [[CPU]]s, or across a [[computer cluster|cluster]] of machines.
Use of threads in [[programming]] often causes a [[state inconsistency]]. A common [[anti-pattern]] is to set a [[global variable]], then invoke [[subprogram]]s that depend on its value. This is known as ''[[accumulate and fire]]''.
|