I have a struct like this:
struct data{ int x; int y; } and I have a thread function that looks like this:
void *threadFunction(void *item){ data *myData = (data*) item; int first = 50; int second = 10; myData->x = first; myData->y = second; return(void*) myData; } I call the thread function like this in main():
pthread_create(threadID, NULL, threadFunction, &item); but when I want to get the values from my thread function back into main() using this:
struct data* returnedItem; pthread_join(threadID, (void**) returnedItem; cout << returnedItem->x << returnedItem->y; I'm not sure what happens as my program seems to just do nothing. It compiles and runs, but it loops infinitely somewhere or just waits on something. I'm not sure what happens at all, I just don't get any sort of response. What am I doing wrong? Is there something I'm missing in main() to retrieve the value from the pthread_join statement? Maybe I screwed up the arguments in the statement?
&item...