Thread (computing): Difference between revisions

Content deleted Content added
m Use of threads in programming often causes an inconsistency in states. The style that sets a number then invoke subprograms can be problematic, which called Accumulate and fire.
m rephrase
Line 5:
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 [[atomic]] operations (often implemented using [[semaphore (programming)|semaphores]]) 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.
 
Use of threads in programming often causes ana state inconsistency. inA states.common The[[anti-pattern]] styleis thatto setsset a numberglobal variable, then invoke subprograms canthat bedepend problematic,on its value. This is whichknown calledas ''[[Accumulateaccumulate and fire]]''.
 
'''See also:''' [[Thread safety]]