Here is the code
Code:
#include <pthread.h>
void* ask_others(void *read_post)
{
int *other_people = (int*)read_post;
int completed_assignment = do_homework();
return &completed_assignment;
}
int main()
{
int messageboard_post;
void *completed_homework;
pthread_t th;
pthread_create(th,0,ask_others,(void*)&messageboard_post);
relax();
have_fun();
wait_for_homework();
pthread_join(th,&completed_homework);
turn_in_homework(completed_homework);
return 0;
}
As you can see, all you have to do is start a new thread where people view your messageboard post. This worker thread essentially does your homework for you. While this thread is working, you call your relax() and have_fun() methods. Finally your worker thread finishes, and you get a pointer to the completed_homework. All that's left to do is call the turn_in_homework() function, passing it the completed_homework reference you got from the worker thread.
Let me know if you have any more questions.