hi all,

i have a problem with pthread programming.

function_1(){
.
.
rc = pthread_create(&thread, &attr, my_function, (void *)&my_data);
.
rc = pthread_create(&thread, &attr, my_function, (void *)&my_data);
.
}

As the above “function_1” do, the “my_function” can be executed any number of time according to our need, but the problem is I have to create threads again and again. I think this is useless, because the input parameters are same at always (do not have to change).

So i want to do this(execute “my_function” regularly) with a one thread which is created at very first. Is this possible..?
please anyone can help me..

Make the thread sleep for some time and execute my_function or else wait for some message to arrive in a message queue and then execute the function my_function.

I'd highly recommend the message queue method above the sleep method...

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.