文件名称:shared_var
-
所属分类:
- 标签属性:
- 上传时间:2013-12-02
-
文件大小:2.63kb
-
已下载:2次
-
提 供 者:
-
相关连接:无下载说明:别用迅雷下载,失败请重下,重下不扣分!
介绍说明--下载内容来自于网络,使用问题请自行百度
在linux环境下编写一个控制台应用程序,程序中有一个共享的整型变量shared_var,初始值为0;创建一个线程并使其立即与主线程并发执行。新创建的线程与主线程均不断地循环,并输出shared_var 的值。主线程在循环中不断地对shared_var 进行加1操作,即每次循环shared_var 被加1;而新创建的线程则不断地对shared_var 进行减1 操作,即每次循环shared_var 被减1。观察程序运行的结果,并对你看到的现象进行解释。-In the Linux environment. Write a console application, in the program have a Shared shared_var integer variables, the initial value of 0 Create a thread and make it with the main thread immediately execute concurrently. The newly created thread and the main thread are continuously circulation, and the value of output shared_var. The main thread in a loop to add 1 shared_var continuously operating, namely each loop shared_var added 1 While the newly created thread continuously to minus 1 shared_var operation, namely each loop shared_var was minus 1. Observe the result of the program is running, and to explain the phenomenon of you see.
(系统自动生成,下载前可以参看下载内容)
下载文件列表
shared_var.c
shared_var.out
shared_var.out
1999-2046 搜珍网 All Rights Reserved.
本站作为网络服务提供者,仅为网络服务对象提供信息存储空间,仅对用户上载内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。