【问题标题】:dynamically create 2 conditional variable for pthreads为 pthread 动态创建 2 个条件变量
【发布时间】:2013-05-03 14:26:57
【问题描述】:

Pthreads 相关问题。

假设我想动态创建 2 个条件变量。

这样可以吗:

pthread_cond_t * a = new pthread_cond_t();
pthread_cond_t * b = new pthread_cond_t();

pthread_cond_init(&a , NULL);
pthread_cond_init(&b , NULL);

或者它们是同一个条件变量?

【问题讨论】:

    标签: c++ pthreads conditional


    【解决方案1】:

    它们将是 2 个单独的变量,但它们是指针,因此初始化应该是:

    pthread_cond_init(a , NULL);
    pthread_cond_init(b , NULL);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-04-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多