#include"stdio.h"
#include"pthread.h"
#include"unistd.h"
static shdata=;
void *create(void *arg)
{
printf("New pthread......\n");
printf("shared data=%d \n",shdata);
return(void *);
}
int main()
{
pthread_t tid;
int error;
error=pthread_create(&tid,NULL,create,NULL);
if(error!=)
{
printf("thread is not created...\n");
return -;
}
printf("main pid is %d\n",getpid());
sleep();
printf("线程创建成功!\n");
return ;
} //本文出自 “阿凡达” 博客,请务必保留此出处http://shamrock.blog.51cto.com/2079212/702536

Linux创建线程的更多相关文章

  1. [笔记]linux下和windows下的 创建线程函数

    linux下和windows下的 创建线程函数 #ifdef __GNUC__ //Linux #include <pthread.h> #define CreateThreadEx(ti ...

  2. linux内核中创建线程方法

    1.头文件 #include <linux/sched.h> //wake_up_process() #include <linux/kthread.h> //kthread_ ...

  3. Linux内核线程创建

    本文旨在简单介绍一下Linux内核线程: 先举个例子: 不插U盘,在Linux命令行中输入:ps -el:然后插上U盘,再次输入:ps -el 会发现多出了下面一行(当然还会有其他的,比如scsi相关 ...

  4. linux内核中创建线程方法【转】

    本文转载自:https://www.cnblogs.com/Ph-one/p/6077787.html 1.头文件 #include <linux/sched.h> //wake_up_p ...

  5. 4、linux下应用创建线程

    1.linux创建线程之pthread_create 函数简介 pthread_create是UNIX环境创建线程函数 头文件 #include<pthread.h> 函数声明 int p ...

  6. Linux 进程与线程三(线程比较--创建线程参数)

    int pthread_equal(pthread_t th1,pthread_t th2); pthread_equal函数比较th1与th2是否为同一线程,由于不可以讲pthread_t数据类型认 ...

  7. linux线程笔记1之创建线程

    1 线程与进程的对比 这里有一个笔记详细的阐述 http://blog.csdn.net/laviolette/article/details/51506953 2 创建线程函数 int pthrea ...

  8. Linux posix线程库总结

    由于历史原因,2.5.x以前的linux对pthreads没有提供内核级的支持,所以在linux上的pthreads实现只能采用n:1的方式,也称为库实现. 线程的实现,经历了如下发展阶段: Linu ...

  9. LINUX最大线程数及最大进程数

    查看最大线程数: cat /proc/sys/kernel/threads-max ulimit User limits - limit the use of system-wide resource ...

随机推荐

  1. Page Security

    参见开发文档 Overview This document describes how to build applications that grant selected access to indi ...

  2. java.sql.SQLException: 对只转发结果集的无效操作: last

    出错代码如下:static String u = "user";static String p = "psw";static String url = &quo ...

  3. [CareerCup] 4.7 Lowest Common Ancestor of a Binary Search Tree 二叉树的最小共同父节点

    4.7 Design an algorithm and write code to find the first common ancestor of two nodes in a binary tr ...

  4. [MetaHook] R_SparkShower

    By hzqst void R_SparkShower(float *pos) { TEMPENTITY *tent; tent = efx.CL_TempEntAllocNoModel(pos); ...

  5. diff: /../Podfile.lock: No such file or directory

    从github上下载源码运行会报错:问题1描述: diff: /../Podfile.lock: No such file or directory diff: /Manifest.lock: No ...

  6. .NET MVC框架中控制器接收参数的四种方式

    1.通过路由中的配置的参数名字直接接收(要求:两者同名) routes.MapRoute(                 name: "Default",             ...

  7. php中命名空间的使用

    简单使用 命名空间主要解决函数/类冲突的问题.由于PHP中中不允许函数重载,所以我们要使用的到命名空间的.先看一个简单的例子. <?php namespace A; public functio ...

  8. 第二节Unity3D开发环境安装(windows系统)

        这一节准备安装开发环境. 1. 首先先下载软件包:http://pan.baidu.com/s/1imYVv  4.2版本2.下载完后,解压会看到两个文件(运行第二个安装包) 3.准备安装,这 ...

  9. Nginx下Redmine配置

    安装redmine依赖的所有ruby包 cd .. gem install bundler #注意是在网站根目录下执行 bundle install --without development tes ...

  10. 读代码之htmlParser

    在以前使用HtmlParser时,并未考虑过遇到org.htmlparser.tags之外的Tag怎么处理.直到碰到这样的一个标签,如果不加处理,HtmlParser无法对其进行处理.查阅自定义标签之 ...