Pthreads는 다음과 같은 다양한 동기화 메커니즘을 제공합니다.
Linux : Pthreads를 컴파일 및 링킹 시 -pthread
옵션을 추가해야 한다.
일부 시스템에서는 다른 옵션이나 전처리기 정의가 필요할 수 있습니다.
-lpthread
#include <pthread.h>
int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_function)(void *), void *arg )
pthread_t thread;
pthread_create(&thread, NULL, thread_function, NULL);
thread
: 생성된 스레드를 식별하는 pthread_t
객체입니다.attr
: 스레드 속성을 지정하는 pthread_attr_t
객체입니다.
NULL
을 전달하면 기본 속성을 사용합니다.start_function
: 스레드가 시작될 함수입니다.