title: multithreading function calls
body: <p>i have an array of structures with fields of data and fields with pointers to functions.</p>
  
  <p>what i'm doing now is cycling through array and calling each registered function.</p>
  
  <p>what i need is for each of element in my structures array call registered function in a separate independent thread.</p>
  
  <p>i can post an code example also if needed. sorry for my english :)</p>
  
  <p>posting code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;time.h&gt;
  #include &lt;pthread.h&gt;
  
  #define NTHREAD 3
  
  struct server_t {
      char *name;
  
      int (*triggered)(struct server_t *);
  };
  
  typedef struct server_t server_t;
  
  int triggered1(struct server_t * server)
  {
      if  (time(NULL) % 1 == 0) {
          printf("%s\n", __FUNCTION__);
          pthread_exit(0);
          return 0;
      } else {
          return -1;
      }
  }
  
  int triggered2(struct server_t * server)
  {
      if  (time(NULL) % 2 == 0) {
          printf("%s\n", __FUNCTION__);
          pthread_exit(0);
          return 0;
      } else {
          return -1;
      }
  }
  
  int triggered3(struct server_t * server)
  {
      if  (time(NULL) % 5 == 0) {
          printf("%s\n", __FUNCTION__);
          pthread_exit(0);
          return 0;
      } else {
          return -1;
      }
  }
  
  int main()
  {
      pthread_t threads[NTHREAD];
      int  iret[NTHREAD]; int i = 0;
      server_t servers[] = {
          {"server1", triggered1},
          {"server2", triggered2},
          {"server3", triggered3},
      };
  
      /* 
         So, i have an array of structures. AND i have a main loop. 
         i want to create thread for each element of array, pass 
         structure's "triggered" function as start routine for it. 
         AND i need this start routine to periodically check for something. 
         So below some kind of an em.. code, that supposed to be.
      */
  
      &lt;create_threads(&amp;servers);&gt; // this function must create thread for each element of array
                                  //with structure's "triggered" function as a start routine
                                  //argument
  
      /* after what threads are running and checking what they needed in an infinite loop. */
  
     // ?maybe some code here?
      return 0;
  }
  </code></pre>