简单代码递归 +多线程代码测试pthread

简单多线程代码测试

#include 
#include 
#include 
#include 
#include 
#include 
void * thread_cuntion(void *arg);
void strcc(char *str,int num,int jin,int dq,char fr);
struct strin{
    char frist_char;
    int value;
    int ji;
};

int main (){
    int res;
    pthread_t           a,b;
    void                *result,*result2;
    struct strin         x,y;                               //字典生成参数
    x.frist_char    =   'a';
    x.value         =   3;
    x.ji            =   26;
    y.frist_char    =   '0';
    y.value         =   3;
    y.ji            =   10;

    res =   pthread_create(&a,NULL,thread_cuntion,&x);          //创建线程
    res =  res|| pthread_create(&b,NULL,thread_cuntion,&y);
    if(res!=0)
    {
        perror("thread creadte finish...\n");
        exit(EXIT_FAILURE);
    }

    pthread_join(a,&result);                                    //等待线程结束
    pthread_join(b,&result2);

    printf("%s\n%s\n",(char *)result,(char*)result2);
    exit(EXIT_SUCCESS);
}

void * thread_cuntion(void *arg)
{
    struct strin *tem = arg;
    char *stra;
    char *stra_tem;

    stra    =   (char*)malloc(tem->value);
    memset(stra,tem->frist_char,tem->value);

    strcc(stra,tem->value,tem->ji,0,tem->frist_char);               //字典生成递归

    pthread_exit("su");
}

void strcc(char *str,int num,int jin,int dq,char fr){               //字典生成递归
    if(dq >= num)
    {
        return ;
    }
    for(int x = 0;x

 

你可能感兴趣的:(学习列子)