当前位置:  技术问答>linux和unix

pthread出错

    来源: 互联网  发布时间:2017-01-07

    本文导语:  代码: /* example5.c */ #include  #include  #include  void mythread(void)  /* 定义新线程运行的函数 */ {   int i,ret;   ret = pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL); /* 设置线程的取消状态 */   if(ret != 0)   {     printf("Thread...

代码:

/* example5.c */
#include 
#include 
#include 
void mythread(void)  /* 定义新线程运行的函数 */
{
  int i,ret;
  ret = pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL); /* 设置线程的取消状态 */
  if(ret != 0)
  {
    printf("Thread pthread_setcancelsate failed."); /* 如果取消状态未设置成功,打印错误信息 */
    exit(1);
  }
  ret = pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, NULL); /* 设置线程的取消类型 */
  if(ret != 0)
  {
    printf("Thread pthread_setcanceltype failed.");   /* 如果取消类型未设置成功,打印错误信息 */
    exit(1);
  }
  for(i=0; i

    
 
 
 
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。












  • 相关文章推荐
  • unix/Linux下c/c++ pthread库读写锁函数介绍
  • pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);和pthread_detach(pthread_self()); 有区别吗。怎么我执行的效果不一样
  • pthread_attr_init()及pthread_cond_wait使用疑惑
  • pthread_cond_signal和pthread_cond_wait两个函数是怎么意思?
  • 包含了#include <pthread.h>,为什么还有pthread_create错误?
  • 先pthread_cancel()再pthread_join(),主线程退出?
  • 请问pthread_mutex_lock()和pthread_mutex_unlock()可不可以用于对不同进程的线程进行同步。
  • 请问一下红色字体处的区别,及pthread_self()和pthread_creat()函数第一个参数的区别?
  • pthread_cond_wait 之前的 pthread_mutex_lock 语句 有什么作用,可以不用吗?
  • pthread_cancel和pthread_cond_wait
  • pthread_cond_t和pthread_mutex_t的疑问?
  • pthread_cond_wait 之前的 pthread_mutex_lock 语句 有什么作用,可以不用吗? iis7站长之家
  • LINUX关于pthread_create 和pthread_join
  • Pthread
  • pthread_create成功返回,但pthread_kill(thrdid, 0)返回说进程不存在?
  • 问一个关于pthread线程删除(取消)的问题
  • pthread 阻塞问题
  • pthread_cond_timedwait用来让线程睡眠无效?
  • pthread_cond_timedwait用法
  • 关于线程pthread.h
  • Unix中PThread是干什么用的,创建线程吗---小妹


  • 站内导航:


    特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!

    ©2012-2021,,E-mail:www_#163.com(请将#改为@)

    浙ICP备11055608号-3