.TH PTHREAD_CREATE 3 LinuxThreads .SH NAME pthread_create \- create a new thread .SH SYNOPSIS .B #include .BI "int pthread_create(pthread_t * " thread ", pthread_attr_t * " attr ", void * (*" start_routine ")(void *), void * " arg ");" .SH DESCRIPTION .B "pthread_create" creates a new thread of control that executes concurrently with the calling thread. The new thread applies the function .I "start_routine" passing it .I "arg" as first argument. The new thread terminates either explicitly, by calling .BR "pthread_exit" (3), or implicitly, by returning from the .I "start_routine" function. The latter case is equivalent to calling .BR "pthread_exit" (3) with the result returned by .I "start_routine" as exit code. The .I "attr" argument specifies thread attributes to be applied to the new thread. See .BR "pthread_attr_init" (3) for a complete list of thread attributes. The .I "attr" argument can also be .BR "NULL" , in which case default attributes are used: the created thread is joinable (not detached) and has default (non real-time) scheduling policy. .SH "RETURN VALUE" On success, the identifier of the newly created thread is stored in the location pointed by the .I "thread" argument, and a 0 is returned. On error, a non-zero error code is returned. .SH ERRORS .TP .B "EAGAIN" not enough system resources to create a process for the new thread. .TP .B "EAGAIN" more than .B "PTHREAD_THREADS_MAX" threads are already active. .SH AUTHOR Xavier Leroy .SH "SEE ALSO" .BR "pthread_exit" (3), .BR "pthread_join" (3), .BR "pthread_detach" (3), .BR "pthread_attr_init" (3).