Creating Threads
The following routine is used to create a POSIX thread:
#include <pthread.h>
pthread_create (thread, attr, start_routine, arg)
Here, pthread_create creates a new thread and makes it executable.
This routine can be called any number of times from anywhere within
your code. Here is the description of the parameters:
Parameter Description
thread An opaque, unique identifier for the new
thread returned by the subroutine.
attr An opaque attribute object that may be used to
set thread attributes. You can specify a thread
attributes object, or NULL for the default values.
start_routine The C++ routine that the thread will execute once it is created.
arg A single argument that may be passed to start_routine.
It must be passed by reference as a pointer cast of type void.
NULL may be used if no argument is to be passed.
The maximum number of threads that may be created by a process is implementation
dependent. Once created, threads are peers, and may create other threads.
There is no implied hierarchy or dependency between threads.
No comments:
Post a Comment