标签:for sleep char create ack 启动 10个 run callback
/*----------------------------------------------------------------------------*/ void *thread(void *ptr) { BaseSocks basesock; basesock.run(1,callback); return 0; } void *thread2(void *ptr) { BaseSocks basesock; basesock.run(2,callback); return 0; } void *thread3(void *ptr) { BaseSocks basesock; basesock.run(3,callback); return 0; } void *thread4(void *ptr) { BaseSocks basesock; basesock.run(4,callback); return 0; } void *thread5(void *ptr) { BaseSocks basesock; basesock.run(5,callback); return 0; } void *thread6(void *ptr) { BaseSocks basesock; basesock.run(6,callback); return 0; } void *thread7(void *ptr) { BaseSocks basesock; basesock.run(7,callback); return 0; } int main(int argc, char **argv) { pthread_t id; int ret = pthread_create(&id, NULL, thread, NULL); if(ret) { return 1; } for(int i = 0;i < 3;i++) { sleep(1); } pthread_t id2; int ret2 = pthread_create(&id2, NULL, thread2, NULL); if(ret2) { return 1; } for(int i = 0;i < 3;i++) { sleep(1); } pthread_t id3; int ret3 = pthread_create(&id3, NULL, thread3, NULL); if(ret3) { return 1; } for(int i = 0;i < 3;i++) { sleep(1); } pthread_t id4; int ret4 = pthread_create(&id4, NULL, thread4, NULL); if(ret4) { return 1; } for(int i = 0;i < 3;i++) { sleep(1); } pthread_t id5; int ret5 = pthread_create(&id5, NULL, thread5, NULL); if(ret5) { return 1; } for(int i = 0;i < 3;i++) { sleep(1); } pthread_t id6; int ret6= pthread_create(&id6, NULL, thread6, NULL); if(ret6) { return 1; } for(int i = 0;i < 3;i++) { sleep(1); } pthread_t id7; int ret7= pthread_create(&id7, NULL, thread7, NULL); if(ret7) { return 1; } for(int i = 0;i < 3;i++) { sleep(1); } pthread_join(id, NULL); pthread_join(id2, NULL); pthread_join(id3, NULL); pthread_join(id4, NULL); pthread_join(id5, NULL); pthread_join(id6, NULL); pthread_join(id7, NULL); }
标签:for sleep char create ack 启动 10个 run callback
原文地址:https://www.cnblogs.com/hshy/p/13424505.html