title: How can I pass variable in pthread_cond_signal function?
body: <p>I am new to pthread programming. I am writing one sample code in which I want to transfer variable in pthread_cond_signal() as shown below</p>
  
  <pre><code>pthread_t th1,th2;
  pthread_cond_t con1 = PTHREAD_COND_INITIALIZER;
  pthread_cond_t con2 = PTHREAD_COND_INITIALIZER;
  pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
  
  void* fun(void *gh)
  {
      pthread_mutex_lock(&amp;mutex);
      flag=1;
      pthread_cond_wait(&amp;con1,&amp;mutex);
      printf("This is test\n");
      pthread_mutex_unlock(&amp;mutex);
  }
  
  int main()
  {
      char *s;
      int a;
      s=malloc(sizeof(char)*4);
      printf("Enter thread Number \n");
      scanf("%d",&amp;a);
      sprintf(s,"con%d",a);
      pthread_create(&amp;th1,NULL,fun,NULL);
      sleep(1);
      while(flag==0) //wait until pthread_cond_wait is called  
      {}
      pthread_mutex_lock(&amp;mutex);
      pthread_cond_signal((pthread_cond_t *)s);
      pthread_mutex_unlock(&amp;mutex);
      pthread_join(th1,NULL);
      pthread_join(th2,NULL);
      return 0;
  }
  </code></pre>