Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 5. Using POSIX Threads > Process Termination

Process Termination

When the main thread completes, all the child threads are terminated and their resources freed. We can see this demonstrated if we build and run the code shown in Listing 5.15.

Listing 5.15. Code to Create a Child Thread

#include <pthread.h>
#include <stdio.h>

void* thread_code( void * param )
{
  printf( "In thread code\n" );
}

int main()
{
  pthread_t thread;
  pthread_create( &thread, 0, &thread_code, 0 );
  printf( "In main thread\n" );
}


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free 10-Day Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint