• More Courses
  • MCQs
  • Blog Download
  • Tools
  • Contact


    What is Threads ? (OS)

    Threads are like mini-processes that operate within a single process. Each thread has its own program counter and stack so that it knows where it is. Apart from this, they can be considered the same as process, with the exception that they share the same address space. This means that all threads from the same process have access to the same global variable and the same files. Threads are also called lightweight processes. The table given below shows the various items that a process has compared to the items that each thread has. 

    Uses of Thread

    • Some applications need to perform multiple activities at once that share common data and files. Thus reason behind need of multiple threads. 
    • Ability of parallel entities, within a process to all share common variables and data. 
    • Since threads do not have their own address space, it is easier to create and destroy threads than processes. In fact thread creation is around 100 times faster than process creation. 
    • Thread switching has much less overhead than process switching because threads have few information attached with them. 
    • Performance gain when there is a lot of computing and lot of I/O as tasks can overlap. Pure CPU bound thread application no advantage through
    • Threads are very effective on multiple CPU system for concurrent processing because with multiple CPU's true parallelisms can be achieved

    Threads example