Your structure should live at least as long as your thread. If you're creating a thread and returning from the function that called pthread_create(), the structure allocated on the stack may get overwritten by other data and could cause problems in yo
Passing data on a stack to a thread is not in-and-of its self a bad thing -- it depends upon the context. In this case, I don't care that my main thread has to block until the worker thread is done. – Daniel Santos Apr 27 '13 at 2:44
On each iteration of the loop, you're allocating new memory, each with a different address, so the thing that gets passed to pthread_create() on each iteration is different, so none of your threads ends up trying to access the same memory and you don&
Post a Comment:
Showing 0 Comments: