Overview#
Thread of execution is the smallest sequence of programmed instructions that can be managed independently by a scheduler, which is typically a part of the
Operating System or an
Application.Thread is a locus of control inside a running
Application. Think of it as a place in the
Application that is being run, plus the stack of method calls that led to that place to which it will be necessary to return through.
Just as a process represents a Virtual Machine, the Thread abstraction represents a virtual CPU. Making a new thread simulates making a fresh processor inside the Virtual Machine represented by the process. This new virtual CPU runs the same program and shares the same memory as other threads in process.
Thread differ from traditional multitasking Operating System processes in that:
Systems such as
Windows NT and
OS2 are said to have cheap
threads and expensive
processes; in other
Operating Systems there is not so great a difference except the cost of an address space switch which on some architectures (notably x86) results in a translation lookaside buffer (TLB) flush. (as in
Light-Weight Process)
There might be more information for this subject on one of the following: