HP-UX Reference (11i v1 05/09) - 3 Library Functions N-Z (vol 7)
p
pthread_once(3T) pthread_once(3T)
(Pthread Library)
Rest of the code after initialization.
For a multithreaded process, a simple initialization flag is not sufficient; the flag must be protected against
modification by multiple threads. Consequently, this flag has to be protected by a mutex that has to be ini-
tialized only once, and so on. A multithreaded program should use initialization similar to:
static pthread_once_t once_control = PTHREAD_ONCE_INIT;
extern void initialize();
(void)pthread_once(&once_control, initialize);
Rest of the code after initialization.
AUTHOR
pthread_once()
was derived from the IEEE POSIX P1003.1c standard.
SEE ALSO
pthread_create(3T).
STANDARDS CONFORMANCE
pthread_once(): POSIX 1003.1c.
Section 3−−738 Hewlett-Packard Company − 2 − HP-UX 11i Version 1: September 2005