Lifecycle of a Thread

When a thread is created, a new thread of control is added to the current process. Every process has at least one thread of control, in the program's main() routine. Each thread in the process runs simultaneously, and has access to the calling process's global data. In addition each thread has its own private attributes and call stack.
To create a new thread, a running thread calls the pthread_create() function, and passes a pointer to a function for the new thread to run. One argument for the new thread's function can also be passed, along with thread attributes. The execution of a thread begins with the successful return from the pthread_create() function. The thread ends when the function that was called with the thread completes normally.

A thread can also be terminated if the thread calls a pthread_exit() routine, or if any other thread calls pthread_cancel() to explicitly terminate that thread. A thread can also be terminated by the exit of the process that called the thread.


Step by Step Process

The Pthreads Library Creating a Default Thread pthread_create Syntax pthread_create Return Values Waiting for Thread Termination pthread_join Syntax pthread_join Return Values Simple Threads Example Detaching a Thread pthread_detach Syntax pthread_detach Return Values Creating a Key for Thread-Specific Data pthread_key_create Syntax pthread_key_create Return Values Deleting the Thread-Specific Data Key pthread_key_delete Syntax pthread_key_delete Return Values
Setting Thread-Specific Data pthread_setspecific Syntax pthread_setspecific Return Values Getting Thread-Specific Data pthread_getspecific Syntax pthread_getspecific Return Values Global and Private Thread-Specific Data Example Getting the Thread Identifier pthread_self Syntax pthread_self Return Values Comparing Thread IDs pthread_equal Syntax pthread_equal Return Values Calling an Initialization Routine for a Thread pthread_once Syntax pthread_once Return Values Yielding Thread Execution sched_yield Syntax sched_yield Return Values Setting the Thread Policy and Scheduling Parameters pthread_setschedparam Syntax pthread_setschedparam Return Values Getting the Thread Policy and Scheduling Parameters pthread_getschedparam Syntax pthread_getschedparam Return Values Setting the Thread Priority pthread_setschedprio Syntax pthread_setschedprio Return Values Sending a Signal to a Thread pthread_kill Syntax pthread_kill Return Values Accessing the Signal Mask of the Calling Thread pthread_sigmask Syntax pthread_sigmask Return Values Forking Safely pthread_atfork Syntax pthread_atfork Return Values Terminating a Thread pthread_exit Syntax pthread_exit Return Values Finishing Up Cancel a Thread Cancellation Points Placing Cancellation Points Cancelling a Thread pthread_cancel Syntax pthread_cancel Return Values Enabling or Disabling Cancellation pthread_setcancelstate Syntax pthread_setcancelstate Return Values Setting Cancellation Type pthread_setcanceltype Syntax pthread_setcanceltype Return Values Creating a Cancellation Point pthread_testcancel Syntax pthread_testcancel Return Values Pushing a Handler Onto the Stack pthread_cleanup_push Syntax pthread_cleanup_push Return Values Pulling a Handler Off the Stack pthread_cleanup_pop Syntax pthread_cleanup_pop Return Values

References : Oracle share on :        :  

Love to hear your Views / Guidance / Recommendations on this Post…

Explore the Technology World

Computer Programming Terminologies Computer Programming Terminology is a general word for the group of specialized words or meanings relating to Computer Programming, and also the study of such t ...Read MoreNew features in JDK 12 with IntelliJ IDEADeveloped by JetBrains (formerly known as IntelliJ) ,IntelliJ IDEA is a Java integrated development environment (IDE) for developing computer software. It is av ...Read MoreGoogle Pay API Implementation Demo for AndroidIn this youtube Channel by Android Developers ,Learn how to implement the Google Pay API for Android with just a few lines of code and how it works with your ex ...Read MoreUnit Testing in .NET Core and Azure Devops pipelineUnit testing is a software testing method by which individual units of source code, usage procedures,sets of one or more computer program modules together with ...Read MoreThe mind behind Linux & GIT : Linus TorvaldsLinus Torvalds transformed technology twice — first with the Linux kernel, which helps power the Internet, and again with Git, the source code management ...Read MoreTensorflow and deep learningWith Tensorflow ,deep machine learning transitions from an area of research into mainstream software engineering. ...Read MoreJava program to return all possible permutations from collection of distinct numbersexample of Java program to return all possible permutations from collection of distinct numbers ...Read MoreReal Time Analytics with Spring Application Development FrameworkSpring is the most popular application development framework for enterprise Java.Millions of developers use Spring to build simple, truly portable, fast and fle ...Read MorePath Setting in Java When an application is launched from command prompt Windows OS searches for the executable program in the current working directory. The prompt throws an error ...Read MoreFacebook | whatsapp|Github | Twitter | LinkedIn | Youtube| reddit About | Cookies-Policy | Disclaimer | Site Map | Contact

Call / Visit for New Batch


Why Join Us

  • ➯ Free Demo Classes
  • ➯ No Registration Fee
  • ➯ Interview Questions
  • ➯ Study Materials
  • ➯ Softwares
  • ➯ Aptitude & Reasoning
  • ➯ Placement Assitance


  • MyJava Training Institute ,
  • Plot No.243 , shop No 14 ,
  • Secnd Floor , Zone-II ,
  • M.P.Nagar , Bhopal,
  • Madhya Pradesh ( 462011 )
  • ☎  08871209400 , 7987028543
  • 🌐
FacebookGoogle +TwitterYouTube

MyJava - java Training Institute