HP-UX Reference (11i v3 07/02) - 3 Library Functions N-Z (vol 7)

p
pthread_once(3T) pthread_once(3T)
(Pthread Library)
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.
HP-UX 11i Version 3: February 2007 2 Hewlett-Packard Company 227