HP-UX Reference (11i v2 04/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 initialized 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 2: September 2004 − 2 − Hewlett-Packard Company Section 3−−817