Thread (computing): Difference between revisions

Content deleted Content added
Tenbaset (talk | contribs)
m Relinking to hyper-threading
m linked cluster, corrected semaphore
Line 3:
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 memory and other resources directly. On operating systems 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.
 
An advantage of a multi-threaded program is that it can operate faster on machines that have multiple CPUs, or across a [[computer cluster|cluster]] of machines. This is because the threaded nature of the algorithms allow true simultaneous and independent processing. In such a case, the programmer needs to be careful to avoid [[race condition]]s, and other non-intuitive behaviors. 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 an [[atomic]] operationoperations known(often asimplemented ausing [[semaphore (programming)|semaphoresemaphores]]) in order to prevent data from being simultaneously modified, or read while in the process of being modified. Careless use of such primitives can lead to [[deadlock]]s.
 
'''See also:''' [[Thread safety]]