pthread多线程编程
线程函数需要声明为void*
类型。
1 |
|
重要函数:
- Create a new thread
pthread_create()
1 | int pthread_create( |
Return value: 0 if successful. Error code from
Notes: Use a structure to pass multiple arguments to the start routine.
- Wait for a thread to terminate
pthread_join
1 | int pthread_join( |
Return value: 0 for success. Error code from
Notes: Once a thread is joined, the thread no longer exists, its thread ID is no longer valid, and it cannot be joined with any other thread.
- Get my own thread ID
pthread_self
1 | pthread_t pthread_self(); |
Return value: The ID of the thread that called this function.
本文作者 : preccrep
原文链接 : https://preccrep.github.io/2021/03/18/pthread%E5%A4%9A%E7%BA%BF%E7%A8%8B%E7%BC%96%E7%A8%8B/
版权声明 : 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明出处!
留下足迹