zoukankan      html  css  js  c++  java
  • cocos2dx,Ios里面多线程的用法

    代码如下:

    void *threadProcessFunction(void *ptr)

    {

    printf("enter thread\n");

    //do thread thing


    //exit thread

    printf("exit thread\n");

    return NULL;

    }

    void startRequestThread()

    {

        // Create the thread using POSIX routines.

        pthread_attr_t  attr;

        pthread_t       posixThreadID;

        int             returnVal;

        

        returnVal = pthread_attr_init(&attr);

        assert(!returnVal);

        returnVal = pthread_attr_setdetachstate(&attr,PTHREAD_CREATE_DETACHED);

        assert(!returnVal);

        int threadError = 0;


        threadError = pthread_create(&posixThreadID, &attr, &threadProcessFunction, (void*)value);

        returnVal = pthread_attr_destroy(&attr);

        assert(!returnVal);

        if (threadError != 0)

        {

            printf("create thread error");

        }

    }
  • 相关阅读:
    第十二周工作总结
    第八周工作总结
    冲刺2
    冲刺1
    用户场景分析
    用户场景分析
    水王在哪
    课堂练习-4个数的和
    《大道至简》第一章读后感
    ELF Format 笔记(三)—— Section Types
  • 原文地址:https://www.cnblogs.com/secbook/p/2655398.html
Copyright © 2011-2022 走看看