pthread

    技术2022-05-11  57

             由于pthread库不是Linux系统默认的库,所以在使用pthread_create创建线程时,在编译中请加-lpthread参数,例如:

    #include "pthread.h"

    #include "stdio.h"

    void* thread_test(void* ptr)

    {

        printf("test");

    }

    int main()

    {

        pthread_t pid;

        pthread_create(&pid, NULL, test_thread, NULL);

        return 0;

    }


    最新回复(0)