title: C pthread: How to wake it up after some time?
body: <p>I would like to wake up a pthread from another pthread - but after some time. I know signal or pthread_signal with pthread_cond_wait can be used to wake another thread, but I can't see a way to schedule this.  The situation would be something like: </p>
  
  <pre><code>THREAD 1:
  ========
  while(1)
      recv(low priority msg); 
      dump msg to buffer 
  
  
  THREAD 2:
  ========
  while(1)
      recv(high priority msg); 
      ..do a little bit of processing with msg .. 
      dump msg to buffer 
  
      wake(THREAD3, 5-seconds-later);  &lt;-- **HOW TO DO THIS? ** 
      //let some msgs collect for at least a 5 sec window. 
      //i.e.,Don't wake thread3 immediately for every msg rcvd. 
  
  
  THREAD 3: 
  =========
  while(1)
      do some stuff .. 
      Process all msgs in buffer 
      sleep(60 seconds). 
  </code></pre>
  
  <p>Any simple way to schedule a wakeup (short of creating a 4th thread that wakes up every second and decides if there is a scheduled entry for thread-3 to wakeup). I really don't want to wakeup thread-3 frequently if there are only low priority msgs in queue. Also, since the messages come in bursts (say 1000 high priority messages in a single burst), I don't want to wake up thread-3 for every single message.  It really slows things down (as there is a bunch of other processing stuff it does every time it wakes up). </p>
  
  <p>I am using an ubuntu pc. </p>