4

posix 进程 vs. 线程

 2 years ago
source link: https://forrestsu.github.io/posts/cpp/posix-process-vs-thread/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

posix 进程 vs. 线程

2017年3月22日
| 字数 296
| CPP
| 阅读 29

进程和线程api对比

进程 线程 pid_t thread_t fork pthread_create waitpid pthread_jion exit pthread_exit 在main函数中调用return 在线程函数中调用return 僵进程 僵线程 wait_pid pthread_jion

pthread_detach kill pthread_cancel

1 使用pthread_detach 方法脱离一个线程就不会产生僵线程。 2 获取当前县城id

3 pthread_cancel可以杀死一个执行中的线程。

自杀: pthread_exit ,在线程入口函数中调用return. 他杀: pthread_cancel


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK