p The .Fn thrd_create function is used to create a new thread, calling .Fa func with the .Fa arg parameter. This function initializes the .Fa thr object with the identifier of the newly created thread. The completion of .Fn thrd_create is synchronized with the start of the newly produced thread. It is possible to reuse the .Fa thr object once the thread has terminated either by joining another thread operation or been detached.
p The .Fn thrd_current function returns the thread identifier of the current thread.
p The .Fn thrd_detach function is used to indicate that storage for the .Fa thr object can be reclaimed on the thread's termination. The .Fa thr object cannot be already detached or joined.
p The .Fn thrd_equal function is used to check whether two .Fa t1 and .Fa t2 objects refer to the same thread.
p The .Fn thrd_exit function terminates the calling thread and passes the .Fa res value that might be read by the .Fn thrd_join function. The program terminates once all threads have been terminated with an exit code equivalent to calling the .Xr exit 3 function with the .Dv EXIT_SUCCESS status. The .Fn thrd_join function joins the .Fa thr thread, waiting and blocking until it has terminated. The .Fa res parameter points to a variable that will store the status passed from the joined function. If .Fa res is .Dv NULL then the status from the .Fn thrd_exit function is ignored.
p The .Fn thrd_sleep function suspends execution of the calling thread until either a signal is received or the interval specified in the .Fa duration argument has been passed. The .Fa remaining parameter stores requested timeout reduced with the time actually suspended. This argument is used when .Fn thrd_sleep has been interrupted. It is valid code to point both arguments .Fa duration and .Fa remaining to the same object. It is not guaranteed that sleep will not take longer than specified in .Fa duration , however unless interrupted with a signal it will not take shorter than the specified interval.
p The .Fn thrd_yield function yields a process voluntarily and gives other threads a chance to run without waiting for any involuntary preemptive switch. .Sh RETURN VALUES The .Fn thrd_create function returns .Dv thrd_success on success, otherwise .Dv thrd_nomem if not sufficient memory could be allocated, or .Dv thrd_error on other errors.
p The .Fn thrd_current function returns the identifier of the calling thread.
p The .Fn thrd_detach function returns .Dv thrd_current on success or .Dv thrd_error on failure.
p The .Fn thrd_equal function returns zero if .Fa t0 and .Fa t1 refer to the different threads, otherwise it will return non-zero.
p The .Fn thrd_exit function does not return.
p The .Fn thrd_join function returns .Dv thrd_success on success or .Dv thrd_error on failure.
p The .Fn thrd_sleep function returns 0 on success (as the requested time has elapsed), -1 once the function was interrupted by a signal, or a negative value to indicate error. The .Nx implementation returns -2 on error.
p The .Fn thrd_yield function returns no value. .Sh SEE ALSO .Xr nanosleep 2 , .Xr pthread_create 3 , .Xr pthread_detach 3 , .Xr pthread_equal 3 , .Xr pthread_exit 3 , .Xr pthread_join 3 , .Xr pthread_self 3 , .Xr sched 3 , .Xr threads 3 .Sh STANDARDS The .Nm interface conforms to .St -isoC-2011 . .Sh HISTORY This interface first appeared in .Nx 9 . .Sh AUTHORS .An Kamil Rytarowski Aq Mt kamil (at] NetBSD.org