-
pthread_create( ):
int pthread_create(pthread_t *threadID, const pthread_attr_t *attr,
void *(*start_routine) (void *), void *arg);
Effect: create a new thread that starts executing
in the function start_routine
Return value: 0 --> success
≠ 0 --> error code
Parameters:
threadID contains the ID of the new thread upon return
attr specify the attributes for the new thread (later)
start_routine start function for the new thread
arg parameter for the start_routine (later)
|
-
Typical way to used
pthread_create( ):
if ( pthread_create(&tid, &attr, startFunction, &x) != 0 )
{
perror("pthread_create"); // Print cause of error
exit(1);
}
|
|