亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費注冊 查看新帖 |

Chinaunix

  平臺 論壇 博客 文庫
最近訪問板塊 發(fā)新帖
查看: 1797 | 回復(fù): 3
打印 上一主題 下一主題

thread problem [復(fù)制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報告]
發(fā)表于 2010-12-04 13:41 |只看該作者 |倒序瀏覽
本帖最后由 zhuizhuziwo 于 2010-12-04 14:15 編輯

what a fucking day.there is no chinese in this system.so i use english. sorry.

I have written a program with two threads. but it has some errors.

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <unistd.h>
  4. #include <pthread.h>
  5. #include <string.h>
  6. #include <semaphore.h>
  7. #define MAX_LINE_LEN  256

  8. //the second thread.
  9. void * FirstThread(void *arg)
  10. {
  11.     printf("Thread: %s\n", (char *)arg);
  12.     //return EXIT_SUCCESS;
  13.     return EXIT_FAILURE;                              
  14.     //exit(EXIT_SUCCESS);                   //if this thread end with this ,there is no problem.
  15. }

  16. //main thread.
  17. int main()
  18. {
  19.     pthread_t  ptd;
  20.     int rst;
  21.     char str[MAX_LINE_LEN];

  22.     printf("Input string<short<255>:");
  23.     scanf("%s", str);
  24.     rst = pthread_create(&ptd, NULL, FirstThread, (void *)str);
  25.     if(rst != 0)
  26.     {
  27.         //perror("create thread error int %s, %d",__FILE__, __LINE__);
  28.         exit (EXIT_FAILURE);
  29.     }

  30.     void *p_thrdRst;
  31.     rst = pthread_join(ptd, &p_thrdRst);
  32.     if(rst != 0)                                  //last time i forgot this line.
  33.     {
  34.         perror("Error join.\n");
  35.         exit (EXIT_FAILURE);              
  36.     }

  37.     printf("Exit success\n");
  38.     printf("Return string:%s\n", (char *)p_thrdRst);
  39.     return EXIT_SUCCESS;
  40. }
復(fù)制代碼
the print out has an addtional string:  ": Success", i dont know why?
i run it like this.

Input string<short<255>:whdllo
Thread: whdllo
Error join.
: Success                                //Why??? it seems the perror calls print this message.

論壇徽章:
0
2 [報告]
發(fā)表于 2010-12-04 14:16 |只看該作者
i have fixed this problem.thank you all.

論壇徽章:
1
2015年辭舊歲徽章
日期:2015-03-03 16:54:15
3 [報告]
發(fā)表于 2010-12-05 13:36 |只看該作者
what a fucked code

論壇徽章:
0
4 [報告]
發(fā)表于 2010-12-06 13:28 |只看該作者
您需要登錄后才可以回帖 登錄 | 注冊

本版積分規(guī)則 發(fā)表回復(fù)

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報專區(qū)
中國互聯(lián)網(wǎng)協(xié)會會員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP