These fixes are worth reading if your computer displays pthread_join error code 3.

There are often ESRCH error rules – this means that the stream you are definitely trying to join does not exist.

And this is because of the horrible undefined behavior that your code uses in terms of practical ideas for handling thread IDs.

  pthread_t * RequestersThreads = new pthread_t [Length_Tasks]; 

This creates an array attached to N threads, then you no doubt pass a pointer to that set to your function

  initRequestThreads (& RequestersThreads); 
  threads [i] corresponds to the new pthread_t;pthread_create (& (* threads [i]), & attr / * ... * / 

This is where you screw up your 100% choice and trigger undefined behavior. In your individual function, Threads is not a mixture! This is the address of most tables. You won’t be able to access it if you take into account the index of the array operator ( [] ). And the rest is just another insult if you must have been injured here before.

If your company is writing C ++ 11 and higher (as in You 2017), C ++ 11 should use std :: thread . If for some reason you are successfulI’ve been using C ++ 2003, at least end your terrible business with dynamic arrays that pass a pointer to them too, and use std :: vector
as a performance parameter for your function.



 #include  int pthread_join (pthread_t thread, empty ** retval); 


pthread_join error code 3

The pthread_join () function waits for the potion specified by Thread to cancel the command. If thisThe thread has already ended, pthread_join () can return immediately. A stream that can be identified by a stream must be attachable.

If retval is definitely not null, pthread_join () replicates the exit state of the target publication (that is, the value returned by the specific target thread.pthread_exit (3)) at our location at * retval. If the target stream has been canceled, PTHREAD_CANCELED is placed in* reval.

If multiple subjects try to join the same chain at the same time, the result will be undefined. If the thread call pthread_join () is possibly canceled,then the target thread is Joinable (i.e. it does not choose to disconnect) .value


Returns Success, Pthread_join () Returns To 0; If An Error Occurs, A Large Error Number Is Returned.


Deadlock detected (for example, several threads are trying to connect to each other); or thread specifies the entire calling thread.
stream. not perfect connection thread.
Another thread is already waiting to join this thread.
Typically, the authentication thread cannot be found.



After a successful call to pthread_join (), the caller is confident that the thread has been processed.completed.

Joining someone who has already joined with care results in undefined behavior.

The connection failed for a sufficient reason to allow the thread to connect (i.e. avoid this tutorial because any zombie threaduses some network resources, and when there is enough talk about zombies, you won't have time to create new clothes (or processes).

There is no pthread analogue of & status, waitpid (-1, 0), which simply means “connect to everycompleted stream ". If you feel like you need this feature in turn,You will probably need to rethink your object design.

All threads in certain types of peer-to-peer processes: each thread is associated by a process with all other threads.


See Also


POSIX streams in correct order for Windows - REFERENCE -Pthreads-w32


pthread_timedjoin_np - must wait for another message to completePause



pthread_join interrupts execution of the calling threaduntil the end of the wire indicated by th, or throughCall pthread_exit (3) and it can come from. becanceled.

If thread_return is literally NULL and not its associated return valueis saved at the location pointed to by thread_return. vThe return value of th is either the argument it doespthread_exit (3) gave, orPTHREAD_CANCELED if canceled.

Neat Threaded Knotshould be able to connect: this situation should not be disconnectedpthread_detach (3) orPTHREAD_CREATE_DETACHED attribute for pthread_create(3)...

pthread_join error code 3

When any connected thread kills, don't forget about resources (threadHandle and stack) are actually freed for another threadto do this, run pthread_join. Hence pthread_joinmust be called once for each attached thread created to avoid memorya leak.

pthread_timedjoin_np is the same as pthread_join, exceptthat it returns a specific ETIMEDOUT error when the target isdid not leave the post before the end of the voting. When the voteA NULL function that persists forever, and hence its behaviorbe the same as pthread_join.

pthread_tryjoin_np is the same as pthread_join, except thatit will return EBUSY immediately with an error if any of our target threadsI can't leave.

With a specific number, a thread can wait for a specific thread to finish.Calling pthread_join from one thread and anotherThe thread is already waiting for completion and throws an error.


pthread_join, pthread_tryjoin_np andpthread_timedjoin_np Endings are points. WhenUndoubtedly, the thread will be interrupted when suspended in bothFunction, playback continues immediately, andCancellationis made without waiting for translation.break up. If Cancel is displayed while any of the functions are in progress,Streams that are not normally connected.

Return Value

On success, the main th return value is stored inThe position pointed to by thread_return and 0 returns toerror, the best error code returned is not zero.


The stream cannot be found, so it matches the specified th.
-I branch is allowed.
The other is a stream that is already waiting for its end.
(pthread_timedjoin_nponly): successfulbefore it can bejoined.
The th argument refers to a location call.


See Also