进程创建线程,每个线程可以共享进程的地址空间;但同时线程需要保留一些自己私有的数据
unix中的thread独自持有的资源:
- Stack pointer
- Registers
- scheduling properties(policy and priority)
- set of pending and blocked signals
- Thread specific data
- Changes made by one thread to shared system resources will be seen by all other threads
- Two pointers(may belong by different threads) have the same value point to the same data
- Reading and Writing to the same memory locations need explicit synchronization by programmer
- Light weight: can be created with less overhead(process: fork(); thread: pthread_creat())
- Efficient communication / Data exchange(not copy data opration, just need to pass address)