Thread

From StudyWiki

Jump to: navigation, search


Overview

Threads running within a program (which executes within a process)
Thread
A thread is an independent sequence of execution within the program
  • a thread is similar to a process
    • both have single sequential flow of control with a start and end
    • at any time a thread has a single point of execution
    • a thread has its execution stack and program counter
    • sometimes a thread is called a lightweight process
  • a thread differs from a process
    • threads cannot exist independently
    • usually created and/or controlled by a process
    • threads can share a process' resources, including memory and open files
  • some languages support thread programming


Thread Application Example

An application that doesn't use threads
  • Threads typically used in the server side
  • conventional database system uses one process per request
  • OS may be overwhelmed by too many active processes
An application that uses threads

Therefore:

  • Server provides come real processes
    • they act as virtual processors
  • each virtual processor runs multiple threads
  • thread based database system uses 1 thread per request
Personal tools