设为首页收藏本站

LUPA开源社区

 找回密码
 注册
文章 帖子 博客

linux下的c语言开发(多线程编程)

2012-3-1 10:41| 发布者: 红黑魂| 查看: 6290| 评论: 0|来自: csdn博客

摘要:   多线程和多进程还是有很多区别的。其中之一就是,多进程是linux内核本身所支持的,而多线程则需要相应的动态库进行支持。对于进程而言,数据之间都是相互隔离的,而多线程则不同,不同的线程除了堆栈空间之外所 ...
       和我们以前编写的程序有所不同,多线程代码需要这样编译,输入gcc thread.c -o thread -lpthread,

编译之后你就可以看到thread可执行文件,输入./thread即可。

  1. [test@localhost Desktop]$ ./thread  
  2. this is func_1!  
  3. this is func_2!  
  4. this is func_1!  
  5. this is func_1!  
  6. this is func_2!  
  7. this is func_1!  
  8. this is func_1!  
  9. this is func_2!  
  10. this is func_1!  
  11. this is func_1!  

酷毙

雷人

鲜花

鸡蛋

漂亮
  • 快毕业了,没工作经验,
    找份工作好难啊?
    赶紧去人才芯片公司磨练吧!!

最新评论

关于LUPA|人才芯片工程|人才招聘|LUPA认证|LUPA教育|LUPA开源社区 ( 浙B2-20090187 浙公网安备 33010602006705号   

返回顶部