C Libraries/pthread

From Software Engineers Wiki
Jump to: navigation, search

Creating and terminating threads

  • pthread_create(): Create a thread
       int pthread_create(pthread_t *restrict thread,
              const pthread_attr_t *restrict attr,
              void *(*start_routine)(void*), void *restrict arg);
  • pthread_exit(): Terminate current thread
       void pthread_exit(void *value_ptr);
  • pthread_cancel(): Cancel execution of a thread
       int pthread_cancel(pthread_t thread);

Managing threads

  • pthread_join(): Wait for thread termination
       int pthread_join(pthread_t thread, void **value_ptr);
  • pthread_detach(): Detach a thread. Storage for the thread can be reclaimed when that thread terminates. This does not cause the thread to terminate.
       int pthread_detach(pthread_t thread);
Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox