Linux创建线程使用

int pthread_create(pthread_t *thread, const pthread_attr_t *attr,
                   void *(*start_routine)(void *), void *arg)

Linux线程的几种结束方式:

  1. 调用pthread_exit(exit_code)exit_code为线程退出的状态代码。同一进程下的其他线程可以通过pthread_join(exit_code)来使用。
  2. 函数start_routine使用return返回,与调用pthread_exit()作用相同。
  3. 线程被取消pthread_cancel()
  4. 同一进程中的其他线程调用了exit(),,或者主线程从main函数返回。

相关文章:

  • 2021-10-16
  • 2022-12-23
  • 2022-12-23
  • 2021-12-15
  • 2022-12-23
  • 2021-11-23
  • 2022-01-01
  • 2021-06-29
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-08-14
  • 2021-10-15
  • 2021-11-18
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案