Content deleted Content added
some rewording |
m disambig |
||
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 (computers)|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]]. Threads is a way for a [[computer program|program]] to split itself into two or more simultaneously running [[task]]s.
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 [[application]] more readily responds to user's interaction.
Line 8:
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. This is because the threads of the program naturally lend themselves for truly [[concurrent programming|concurrent]] [[execution (computers)|execution]]. In such a case, the [[programmer]] needs to be careful to avoid [[race condition]]s, and other non-intuitive [[behavior]]s. In order for data to be correctly manipulated, threads will often need to [[rendezvous]] in time in order to process the data in the correct order. Threads may also require [[Atomic_(computer_science)|atomic]] operations (often implemented using [[semaphore (programming)|semaphores]]) in order to prevent common data from being simultaneously modified, or read while in the process of being modified. Careless use of such [[primitive]]s can lead to [[deadlock]]s.
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]]''.
|