I used pthread_create created a child thread for http requested,after i get the data i want to call the main thread to do some update of UI.
pthread_detach();
pthread_exit();
pthread_join();
The three function which can use for that?Why?
Is there any warm-hearted person to solve my confusion? A lot of thanks!
The honest answer is none of the above. There is no way to call the main thread from the child thread, but that does not mean you can't do what you are trying to.
A child thread shares the same memory space as the parent thread. What you need to do is create a way for the child thread to inform the parent that it wants to send a message to the user (UI). This could be done a number of different ways, but a simple method would be to provide a function that just takes the message you want to send and puts it onto a queue.
The main thread would just need to check that queue occasionally for any messages and pull them off when it sees one on there to put onto the UI.
You would of course need to make sure that pushing/popping from that queue was controlled with a mutex lock, but since we're talking about messages to the user it shouldn't be something you're doing too often and should not cause any real performance problems.
As I mentioned, this is only one idea for how you could do this. While there are many ways, the basic idea is that the threads need a way to communicate with each other.