在Linux操作系统层面,线程其实只是特殊的进程,最特殊之处在于跟其他“线程进程“共享内存(包括代码段.数据段等,但不共享栈). 这两天看书老是看到线程组(thread group),但是线程组是什么呢?百思不得其解,幸好有StackOverflow,不多说,先上链接:<If threads share the same PID, how can they be identified?> 讲一讲我的理解. 熟悉Linux下C编程的同学都知道,每个进程都有自己的pid,每个线程都有自己的线程id
用个栗子来说明吧from multiprocessing import Processimport time,os def task(): print('%s is running ,parents id is<%s>'%(os.getpid(),os.getppid())) time.sleep(3) #自己id 父id print('%s is done ,parents id is<%s>'%(os.getpid(),os.getppid())) if __name__ ==