#include <cstdatomic>

using namespace std ;

atomic<int> i ;

int main()
{
    int iCPU = 0 ;
    pthread_t tid1,tid2,tid3 ;
    void*status;

    void   *dosendconfig(void *);
    pthread_create(&tid1, NULL, &dosendconfig, (void *)(long) iCPU );
    iCPU = 1 ;
    pthread_create(&tid2, NULL, &dosendconfig, (void *)(long) iCPU );
    iCPU = 2 ;
    pthread_create(&tid3, NULL, &dosendconfig, (void *)(long) iCPU );

    pthread_join(tid1,&status) ;
    pthread_join(tid2,&status) ;
    pthread_join(tid3,&status) ;
    cout << i << endl ;
} //main

void * dosendconfig(void *arg)
{
    for(int idx=0;idx<100000000;idx++)
        i++ ;
}

 

arrow
arrow
    全站熱搜

    hedgezzz 發表在 痞客邦 留言(0) 人氣()