Threading

A thread is defined as the execution path of a program. Each thread defines a unique flow of control. If your application involves complicated and time-consuming operations, then it is often helpful to set different execution paths or threads, with each thread performing a particular job.

Threads are lightweight processes. One common example of the use of thread is the implementation of concurrent programming by modern operating systems. The use of threads saves wastage of the CPU cycle and increase the efficiency of an application.

So far we wrote the programs where a single thread runs as a single process which is the running instance of the application. However, this way the application can perform one job at a time. To make it execute more than one task at a time, it could be divided into smaller threads.

Thread Life Cycle

The life cycle of a thread starts when an object of the System.Threading.Thread class is created and ends when the thread is terminated or completes execution.

Following are the various stages in the life cycle of a thread ?

The Unstarted State ? It is the situation when the instance of the thread is created but the Start method is not called.


The Ready State ? It is the situation when the thread is ready to run and waiting CPU cycle.

The Not Runnable State ? A thread is not executable, when

  1. Sleep method has been called
  2. Wait method has been called
  3. Blocked by I/O operations

The Dead State ? It is the situation when the thread completes execution or is aborted.

Hossam Farag

Application Support Lead at eBSEG

4 年

congratulations

回复

要查看或添加评论,请登录

Shazly Abozeid的更多文章

  • System Design

    System Design

    System Design is the process of designing the architecture, components, and interfaces for a system so that it meets…

  • Monolithic vs Microservices architecture

    Monolithic vs Microservices architecture

    this article @https://www.geeksforgeeks.

  • Traditional Deployment VS Virtualization VS Container

    Traditional Deployment VS Virtualization VS Container

    History of running a software Traditional Deployment Early on, organizations ran applications on physical servers…

    3 条评论

社区洞察

其他会员也浏览了