zoukankan      html  css  js  c++  java
  • linux OS 多线程学习

    /***********************
    * author :lzhenf
    * it's a program with args for mutithread in linux OS
    * date:2012.3.27
    * **********************
    */
    #include <stdio.h>
    #include <pthread.h>

    void* mythread(void* args)
    {
    char *str1;
    str1 = (char *)args;
    sleep(5);
    printf("the thread id is %u",(unsigned int )pthread_self());
    printf("the thread id num is %d",getpid());
    printf("create parameter is %s\n",str1);
    return (void*)0;
    }

    int main(int argc ,char *argv[])
    {
    pthread_t id;
    int error;

    char a[]="lzhenf";
    char *p = a;

    error = pthread_create(&id , NULL , (void*)mythread,(void*)p);

    if (error)
    {
    printf("the create is error\n");
    return -1;
    }
    sleep(1);
    printf("pthread_create is created \n");
    pthread_join(id,NULL);

    return 0;
    }
  • 相关阅读:
    如何找回Oracle所有用户丢失的密码
    数据库范式详解
    lua
    cdn
    初心
    广州
    vim 命令
    git 命令
    Linux琐碎
    汪国真语录
  • 原文地址:https://www.cnblogs.com/lzhenf/p/2419658.html
Copyright © 2011-2022 走看看