Hello,

I want to create a very simple program to test threading. Example

int main () {

   char option = 'a';
   int run = 1;

   while ( option != 'x' ) {
      option = getch ();
      /* some code that changes run */

     /* thread ? */
   }

}

Now I wanted a thread to run every X seconds, displaying some message (like the value of the run variable).

How can this be accomplished?

Thanks for your help.

Hello,

some hits, tips, tricks...

Thanks.

Well it's working Ok. managed to work it out from examples.

1) Just created a thread with

pthread_t newThreadName;

2) Then "attached" (not sure to what's the expression) the newThreadName to a function with pthread_create

3) Then just added some timing logic within a loop in the new function.

...

If someone knows other ways please say so.

Thank.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.